Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow running pytest from local host #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

Copy link
Contributor

@ebreton ebreton commented Apr 13, 2019
edited
Loading

Running tests should be lightning fast. I was (maybe un-rightely) using the script from scripts/tests-local.sh, which takes care of building fresh containers, starting them and then running the tests.

I will keep this process for automatic tests (probably on git hooks)...
This PR provides a way to run pytest locally during base development

Therefore

$ cookiecutter full-stack-fastapi-postgresql/ --no-input
$ cd base-project
$ docker-compose up -d
$ cd backend/app/
$ pipenv install --dev
...
$ pipenv shell
$ pytest

and tada ! 🎉

================================= test session starts ==================================
platform darwin -- Python 3.7.3, pytest-4.3.0, py-1.7.0, pluggy-0.8.1
rootdir: /Users/emb/git-repos/github/base-project/backend/app, inifile:
plugins: celery-4.2.1
collected 17 items
app/tests/api/api_v1/test_celery.py . [ 5%]
app/tests/api/api_v1/test_token.py .. [ 17%]
app/tests/api/api_v1/test_user.py ...... [ 52%]
app/tests/crud/test_user.py ........ [100%]
============================== 17 passed in 6.16 seconds ===============================

There is however this new .env file that the users should be aware of... but that definitevely worth the price IMHO 👶

Copy link
Member

Thanks, I'll check it soon.

Copy link
Member

The problem here is that the .env file will end up in the container too, and it can create problems there.

Apart from requiring another file with variables that the user has to take care of.

Also, you can run more or less the same with:

cookiecutter full-stack-fastapi-postgresql/ --no-input
cd base-project
docker-compose up -d
docker-compose exec backend-tests /tests-start.sh

The benefit is that the tests are being run in an environment equivalent to production, the server is communicating with its own DB, independent of if there are other DBs up in the same port or similar things.

On another note, I plan on including the tests in the same image as the backend, so they can be run separately but they can also run in the same container, this will allow enabling and using code coverage, inside the containers.

ebreton reacted with thumbs up emoji

Copy link
Contributor Author

ebreton commented Apr 23, 2019

You are right, I missed the docker-compose exec backend-tests /tests-start.sh

I am looking forward test coverage (which does not look simple between multiple containers) !

Copy link
Member

Great, thanks!

@ebreton ebreton deleted the feature-allow-pytest-from-host branch April 27, 2019 17:36
alejsdev added a commit that referenced this pull request Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /