First time here? Check out the FAQ!
1

using WING_TEST_DJANGO_SETTINGS_MODULE

I am neither a django expert nor an IDE expert and I do not understand how I should use the WING_TEST_DJANGO_SETTINGS_MODULE. Does this file exist ? if so where is it. If it does not exist where should I create it and where should I reference it?

piscvau's avatar
611
piscvau
asked 2021-09-08 04:07:22 -0500
Wingware Support's avatar
4.3k
Wingware Support
updated 2021-09-08 08:23:16 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

5 Answers

0

This is only needed if you are using a different settings module when running unit tests than when running Django normally. You can set it in the Environment in your Project Properties (from the Project menu).

In Wing 8.0.3+ the Django settings module for testing may also be set with --settings=<name> in the Run Args on the Testing page of the Project Properties dialog.

Wingware Support's avatar
4.3k
Wingware Support
answered 2021-09-08 08:22:54 -0500
edit flag offensive 0 remove flag delete link

Comments

Coming back to django tests. I need to use a different settings file for either some tests or all tests that are lauched with manage.py test. I have tried to add the following lines

DJANGO_SITENAME=djangoLudd21 VIRTUAL_ENV= '

in the inherited environment in the launch configuration of certain files. When I stop in the manage.py file, the environment variable is set but the django.setup() seems not to be executed. IN particular the apps registry is not populated.

I have tried to add WING_TEST_DJANGO_SETTINGS_MODULE = the tests setting file module in the project properties in the TestingTab in the environment arera after use ProjectSettings and the following ardgs. No luck . When I stop in the manage.py file this environment variable is not set!....

piscvau's avatar piscvau (2025-07-28 10:32:55 -0500) edit
add a comment see more comments
0

Oups found the solution the WING_TEST_DJANGO_SETTINGS_MODULE is to be inserted in the project properties main tab not test.

piscvau's avatar
611
piscvau
answered 2025-07-28 10:37:16 -0500
edit flag offensive 0 remove flag delete link

Comments

But unfortunately it seems inoperant. Even though I have the variable set im my project properties, the tests are run with the standard settings module

piscvau's avatar piscvau (2025-07-28 11:50:42 -0500) edit

The best way to debug this is to step through the Django setup code. For us to help (and we'd be stepping through the Django setup code), we'd need a test case -- a project that fails in the same way that your project fails.

Wingware Support's avatar Wingware Support (2025-07-28 11:59:09 -0500) edit
add a comment see more comments
0

ANd so I did. I stop in django.setup(). and here the environment variable WING_TEST_DJANGO_SETTINGS_MODULE contains the correct value. But I do expect that the django code is suppose to be aware of this environment variable. Is must be wing code that does something with it which evidently does not happen.

piscvau's avatar
611
piscvau
answered 2025-07-28 13:48:48 -0500
edit flag offensive 0 remove flag delete link

Comments

Line 198 of run_djangotests_xml.py is where WING_TEST_DJANGO_SETTINGS_MODULE is used to set DJANGO_SETTINGS_MODULE So the next questions are probably whether DJANGO_SETTINGS_MODULE is set and whether the Django setup code uses it correctly.

Wingware Support's avatar Wingware Support (2025-07-28 13:53:59 -0500) edit
add a comment see more comments
0

By the way I also tried to stop in run django_tests_xml.py and it never stopped there. Not surprising since this is a test runner which I suppose is used only for the testing tool. SO basically it means that this wing test variable is not used at all for any test that is ran with manage.py but launched with a specific laucnh configuration.

This means that this feature is unusable for laucnhin testserver which I was looking for!....

ANy hack that would be executed when 'test' or 'testserver' is present in the run arguments of a launch configuration would be helpful!....

piscvau's avatar
611
piscvau
answered 2025-07-28 14:02:31 -0500
edit flag offensive 0 remove flag delete link

Comments

Sorry, I thought you were debugging tests through the testing tool. Have you tried setting DJANGO_SETTINGS_MODULE for your launch configuration?

Wingware Support's avatar Wingware Support (2025-07-28 14:16:11 -0500) edit

OK Yes it does work if we copy all the lines from the project properties and put them into . What is the inherited environment?

piscvau's avatar piscvau (2025-07-28 14:49:21 -0500) edit
add a comment see more comments
0

other discovery. Using the WING_TEST_DJANGO_SETTINGS_MODULE in the environment of the project properties makes it impossible to run any test with the testing tool. I crashes in line 100 of run_djangotests_xml.py in the import settings and raises Module not found error.

IN my configuration the settings file is not in the syspath but the DJANGO_SETTINGS_MODULE is referencing the test settngs file.

piscvau's avatar
611
piscvau
answered 2025-07-28 14:16:56 -0500
edit flag offensive 0 remove flag delete link

Comments

Hello I continue this discussion by mail

piscvau's avatar piscvau (2025-07-28 14:50:11 -0500) edit
add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer