Ask Your Question
1

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

asked 2019-12-04 08:14:05 -0600

pymike gravatar image

updated 2019-12-04 08:33:51 -0600

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.

edit retag flag offensive 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 gravatar imageWingware Support ( 2019-12-04 08:35:53 -0600 )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 gravatar imagepymike ( 2019-12-04 09:07:24 -0600 )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 gravatar imageWingware Support ( 2019-12-04 09:13:35 -0600 )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 gravatar imagepymike ( 2019-12-04 09:34:44 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-12-04 09:57:56 -0600

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-12-04 08:14:05 -0600

Seen: 157 times

Last updated: Dec 04