Skip to content

Provide Hook for custom django settings configuration #1001

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

Open
JulianFeinauer opened this issue Mar 21, 2022 · 4 comments
Open

Provide Hook for custom django settings configuration #1001

JulianFeinauer opened this issue Mar 21, 2022 · 4 comments

Comments

@JulianFeinauer
Copy link

We use a setup where we do not use djangos "default" initialization but create our own settings via Djangos settings.configure(xxx).
Currently this is not supported via pytest-django but a very minor change could allow such a functionality.

I think all that would be necessary is the possibility to call a callback before Line 351 (https://github.com/pytest-dev/pytest-django/blob/master/pytest_django/plugin.py#L351).

This change should not have any side effect for existing projects and by default the behavior of the library would not be changed at all.

I will provide a suggestion in the next days for a MWE.

@NiklasMerz
Copy link

Isn't this something like that?

@JulianFeinauer
Copy link
Author

Hmmmm... looks like that... RTFM again, hm?
I will try to adopt my code : )

@NiklasMerz
Copy link

NiklasMerz commented Mar 21, 2022 via email

@JulianFeinauer
Copy link
Author

Feedback here...
It seems that it is at the moment impossible to run a custom database initialization when using pytest-django together with pytest-xdist.
The worker-nodes are then initialized differently and in the pytest_load_initial_conftests Hook the "default" initialization is done for django.

So I think we have to stick to something like this approach

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

No branches or pull requests

2 participants