First time here? Check out the FAQ!
1

django testing keeps adding 'unittest', fails to find some tests

  • retag add tags

My Django unit tests are in 'tests' subdirectory under the project. There are two files in this subdirectory - tests.py and test_auth.py. There is an __init__.py in this subdirectory also. I can directly execute 'python manage.py test tests' just fine.

I have configured Project -> Testing for 'Django Tests'. I have tried with and without 'Test file patterns' set with a glob to the testing subdirectory.

In all cases when I 'Run Tests' the tests in tests.py are executed. The tests in test_auth.py are not executed. In addition there is an error shown "ImportError: Failed to import test module: tests.test_auth".

My configuration seems pretty straightforward, are there any examples how to get this to work? For example, how to configure the equivalent of " $ python manage.py test tests.test_auth" ?

Thanks.

pymike's avatar
196
pymike
asked 2019-12-04 08:14:05 -0500, updated 2019-12-04 08:33:51 -0500
edit flag offensive 0 remove flag close merge delete

Comments

In the Testing tool in Wing, are you seeing manage.py or something else? Also, did you use Project > Extensions > Configure Project for Django or Start Django Project or did you set up the project entirely manually?

Wingware Support's avatar Wingware Support (2019-12-04 08:35:53 -0500) edit

The project is configured for Django, I can execute the app inside WingIDE (Debug I/O below). Its just the testing that doesnt work. I dont see manage.py in the Testing Tool (I see nothing there).

Thanks!

INFO 2019-12-04 15:05:39,192 autoreload 63773 4452783552 Watching for file changes with StatReloader INFO 2019-12-04 15:05:39,192 autoreload 63773 4452783552 Watching for file changes with StatReloader Performing system checks...

System check identified no issues (0 silenced). December 04, 2019 - 15:05:39 Django version 2.2.2, using settings 'cfgsvc.settings' Starting development server at <body>link awaiting moderation</body> Quit the server with CONTROL-C.

pymike's avatar pymike (2019-12-04 09:07:24 -0500) edit

The automated project setup process should add manage.py as a testing file. You can do this manually with the Testing > Add Single File or Add Current File menu item. Once that's done and it's showing up in the Testing too, click on it and press Run Tests. This should run all the tests that would be run from manage.py on the command line.

Wingware Support's avatar Wingware Support (2019-12-04 09:13:35 -0500) edit

What exactly do i type in the 'Add Single File'? Should I also enter something in Testing -> Test file patterns? I have a tests subdirectory off the project directory, there are two python files in that subdirectory. Thanks.

pymike's avatar pymike (2019-12-04 09:34:44 -0500) edit
add a comment see more comments

1 Answer

0

You want to select manage.py as the testing file. Testing > Add Single File should be showing a file open dialog. Is it showing something else? You could also open manage.py in the editor and then do Testing > Add Current File. You don't need to set any Test File Patterns in the project in this case since with Django there is just the one test file (manage.py). That's a way to add many files as test files at once for projects that use other testing frameworks.

You may also want to right click on manage.py, select Properties, and make sure that Test Framework under the Testing tab is showing Django. I think it should if you set that at the project level but worth checking.

Wingware Support's avatar
4.1k
Wingware Support
answered 2019-12-04 09:57:56 -0500
edit flag offensive 0 remove flag delete link

Comments

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