pytest-django icon indicating copy to clipboard operation
pytest-django copied to clipboard

Provide Hook for custom django settings configuration

Open JulianFeinauer opened this issue 3 years ago • 4 comments
trafficstars

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.

JulianFeinauer avatar Mar 21 '22 11:03 JulianFeinauer

Isn't this something like that?

NiklasMerz avatar Mar 21 '22 14:03 NiklasMerz

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

JulianFeinauer avatar Mar 21 '22 14:03 JulianFeinauer

I was just looking for a place to document your new feature and found this that sounds like something very similar 😉

On March 21, 2022, GitHub @.***> wrote:

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

— Reply to this email directly, view it on GitHub <https://github.com/pytest-dev/pytest-django/issues/1001#issuecomment- 1073961182>, or unsubscribe <https://github.com/notifications/unsubscribe- auth/AA3LORGRVQTSBHP2FXQ3XZDVBCA4PANCNFSM5RHNN7VQ>. You are receiving this because you are subscribed to this thread.Message ID: @.***>

NiklasMerz avatar Mar 21 '22 15:03 NiklasMerz

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

JulianFeinauer avatar Jun 27 '22 12:06 JulianFeinauer