miguelgrinberg / microblog-api

A modern (as of 2024) Flask API back end.
MIT License
367 stars 99 forks source link

Question - How to run tests? #8

Closed molinto closed 2 years ago

molinto commented 2 years ago

Hi, big thanks to Miguel for this awesome repo & blog post (https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xv-a-better-application-structure)

I've cloned your repo, made a new model & added a new route, I would now like to write tests from them. I'm trying to run the existing tests in the tests folder, but think I'm doing something wrong. In the blog post it mentions tests.py but this file does not exist any longer, tad confused.

How do you actually run the tests please? Is there a Flash command to run, eg: Flask run tests?

Thank you Sharry

miguelgrinberg commented 2 years ago

I don't understand. This project always had a tests.py and still does. https://github.com/miguelgrinberg/microblog/blob/main/tests.py

molinto commented 2 years ago

Sorry for confusion I'm using the repo: https://github.com/miguelgrinberg/microblog-api

Not https://github.com/miguelgrinberg/microblog

miguelgrinberg commented 2 years ago

@molinto Maybe you don't realize this, but you are mixing up completely different projects and that is the reason why things don't seem to match up.

To run the tests for the Microblog API project (which has absolutely nothing to do with the Flask Mega-Tutorial) install tox and then run tox -e py310, replacing py310 with the version of Python you are using (i.e. py39, py38, etc.).

ondiekelijah commented 2 years ago

Hi, big thanks to Miguel for this awesome repo & blog post (https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xv-a-better-application-structure)

I've cloned your repo, made a new model & added a new route, I would now like to write tests from them. I'm trying to run the existing tests in the tests folder, but think I'm doing something wrong. In the blog post it mentions tests.py but this file does not exist any longer, tad confused.

How do you actually run the tests please? Is there a Flash command to run, eg: Flask run tests?

Thank you Sharry

Hi, please check out these answers from SO. I bet it's what you're looking for.