Skip to content
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

tests: run Test_django_db_blocker in testdir #806

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

blueyed
Copy link
Contributor

@blueyed blueyed commented Jan 18, 2020

Copy link

@SalmonMode SalmonMode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Placing them in a subprocess fix the issue that django_db_blocker currently has. WHen django_db_blocker is requested on its own, the DB is not set up. These tests pass because of the other two tests that trigger the session scope-level django_db_setup fixture. Because they always run first (due to the test reordering logic), the DB will always be prepared for the other two tests (that would fail if run on their own).

The fix I found was to rename django_db_blocker to _django_db_blocker, have django_db_setup use that, and then create a new session scope-level fixture called django_db_blocker which requests both of them. This way, whenever django_db_blocker is called, it ensures the DB is set up.

@blueyed
Copy link
Contributor Author

blueyed commented Jan 18, 2020

@SalmonMode thanks!
Do you want to create a PR for this (in case you have it ready already locally)?
Otherwise I'll do so later.

I think this PR/change still makes sense (separately), since it simulates running the tests alone. And it could be extended then to test what your renaming/re-arranging would fix (in a separate test).

@SalmonMode
Copy link

I'd be happy to 😁

There's some already existing tests I can make tweaked copies of to cover this.

Sorry for causing all the ruckus, btw.

@blueyed
Copy link
Contributor Author

blueyed commented Jan 18, 2020

I'd be happy to

Great. I assume this can be done on top of this one?
I.e. run pytest also with selecting only a single test (not using the db) from it.

There's some already existing tests I can make tweaked copies of to cover this.

I'd rather avoid new tests if existing ones can be extended / hardened - the test suite is rather slow already, especially due to all the runpytest_subprocess tests.

Sorry for causing all the ruckus, btw.

No worries.. :)

@SalmonMode
Copy link

SalmonMode commented Jan 18, 2020

I'd rather avoid new tests if existing ones can be extended / hardened - the test suite is rather slow already, especially due to all the runpytest_subprocess tests.

Not a problem. I can just tweak them in place.

I assume this can be done on top of this one?
I.e. run pytest also with selecting only a single test (not using the db) from it.

Sorry, I'm not sure I follow. You mean if I can make changes on top of the current change you're making here?

@SalmonMode
Copy link

Here's the PR #807

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants