First time here? Check out the FAQ!
1

Difficulties with django tests

I have a very very hard time using Wing testing tool to run django tests. My django project has several apps and only one manage.py file. The different applications are not entirely independant. Sometimes I need to run tests only for one application and somtimes I need to run test for all applications. According to the wing documentation, parameters to the run tests command should be entered as file properties for manage.py. This means I have to change the file properties of the manage.py file each time I want to test only one application. This is very cumbersome and unpractical. Is there any other solution?

piscvau's avatar
526
piscvau
asked 2024-06-02 14:36:02 -0500
Wingware Support's avatar
4.1k
Wingware Support
updated 2024-07-03 08:51:58 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

2 Answers

0

One idea is to have separate Wing projects for each app. You can easily switch from the Project > Recent menu and it makes some sense to separate those.

Alternatively, you could possibly make multiple copies of manage.py and add those to the Testing tool, each with properties set for the one app.

Wingware Support's avatar
4.1k
Wingware Support
answered 2024-06-03 11:45:49 -0500
edit flag offensive 0 remove flag delete link

Comments

May be I missed something but I do not see how I could have multiple copies of manage.py in the same directory. They would have to be renamed and I do not understand how this would work. Wing documentation does say that the file must be named manage.py

piscvau's avatar piscvau (2024-06-03 13:01:55 -0500) edit

The complete solution seems to create manage2.py file with a different name and create a named entry point for this manage2.py file.

piscvau's avatar piscvau (2024-06-04 05:38:15 -0500) edit

Yes, that's what I meant. Is that working for you? You may not need a named entry point if you just set its file properties, and that's needed in any case for the Testing tool to handle it right.

Wingware Support's avatar Wingware Support (2024-06-04 09:17:06 -0500) edit

Yes it does work with a named entry point . This allows to debug a subset of tests from the debug named entry point menu. However these tests do no run within the testing tool. These tests must be unittest.TestCase because they use the schema_editor. in the testing tool, it shows output no test run.

I really wish the handling of the django tests by the wing testing tool be clarified in the wing documentation.

piscvau's avatar piscvau (2024-06-05 00:25:32 -0500) edit

I wasn't talking about running manage2.py in the debugger using a named entry point. That certainly would work but doesn't address the issue of running the tests in the Testing tool. Can you please try using Testing > Add Current File menu item to add manage2.py to the Testing tool, then right-click on the manage2.py editor, select the Testing tab and choose Django Tests for the Test Framework, then select any other environment needed also under the Testing tab, and submit the dialog with OK. Then click on manage2.py in the Testing tool and press the Run or Debug Button... this should work to run or debug the tests using the Django test framework.

All that said, if your tests are not run by manage.py then this isn't the right approach and you would instead add the specific test files to the Testing tool and set their Test Framework to ... (more)

Wingware Support's avatar Wingware Support (2024-06-05 06:31:12 -0500) edit

no this does not work. I get an output system check identified no issue. ran 0 tests

It would largely help if I knew what is under Wings'hood when clicking Django Test or Unittest in the Testing environment.

Yes my tests are ran with manage.py . This is the whole purpose of creating a manage.py2 file. However they do not inherit from django test classes but from unittest.TestCase. but they do need the django setup() that is done by manage.py test

piscvau's avatar piscvau (2024-06-05 09:08:09 -0500) edit

Unfortunately I don't know how to make that work. One idea is to debug the test and set a breakpoint at the top level of your manage2.py so it'll definitely be hit, and then you can look up the stack to see the test runner machinery (both Wing's and Django's), possibly set some breakpoints earlier in the process up the stack, and step through code to better understand what is happening.

The test runner code Wing uses is available in source form in src/testing/runners/run_djangotests_xml.py in your Wing installation. That'll be on the stack if you try debugging and looking up the stack.

From inspecting this code, I suspect I might be wrong about being able to use a manage2.py. The code in there seems to make assumptions that the name entry point for all tests is manage.py, both in how it computes test_name_list, and in how it runs the tests. ... (more)

Wingware Support's avatar Wingware Support (2024-06-05 14:04:38 -0500) edit
add a comment see more comments
0

I think at the moment (Wing 10.0.5) the only answer is to have separate Wing projects for each app. You can easily switch from the Project > Recent menu and it makes some sense to separate those. I'm leaving the other earlier answer in case it's useful at some point, but I think the idea of having other copies of manage.py won't work because of how the Django test runner for Wing is currently designed.

Wingware Support's avatar
4.1k
Wingware Support
answered 2024-08-16 08:27:57 -0500
edit flag offensive 0 remove flag delete link

Comments

Hello I do not understand your statement. I have several applications in the same project and have not encountered difficulties as long as they are coherent with the standard file hierarchy structure.

piscvau's avatar piscvau (2024-08-17 02:53:51 -0500) edit

I'm continuing this discussion via email since it's too confusing to have it half here and half on email. I should note, though, that Wing 10.0.4.4 fixed a problem with running Django tests when setting initial directory in Project Properties, which may be part of the issue that led to this ticket. I'll update this if/when there is more information that might help others.

Wingware Support's avatar Wingware Support (2024-08-17 08:19:34 -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