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

Expose available_apps in django_db marker #1071

Merged
merged 2 commits into from
Oct 25, 2023

Conversation

sullivan-sean
Copy link
Contributor

@sullivan-sean sullivan-sean commented Aug 1, 2023

Right now in a multi-schema environment, TransactionTestCases may fail to flush if there are foreign key dependencies between schemas because the test case will flush the DB in _fixture_teardown (see source) but will not cascade truncation by default.

I've encountered this issue in a multi-tenant environment, and another user has posted about a similar issue here.

Setting available_apps will enable CASCADE during truncation per the django docs (link)

This PR exposes available_apps so that this experimental feature of TransactionTestCase can be used in pytest-django directly.

Addresses #928

Copy link
Member

@bluetech bluetech left a comment

Choose a reason for hiding this comment

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

Thanks, this looks good!

pytest_django/fixtures.py Outdated Show resolved Hide resolved
pytest_django/fixtures.py Outdated Show resolved Hide resolved
pytest_django/plugin.py Outdated Show resolved Hide resolved
@bluetech bluetech enabled auto-merge (squash) October 25, 2023 21:07
@bluetech bluetech merged commit bf9c965 into pytest-dev:master Oct 25, 2023
15 checks passed
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