Jose M Vidal
Jose M Vidal

Reputation: 9158

Pycharm identifies new Django test file as a unittest, not a django test

How do I tell pycharm that the new test file I created is a django test file, and not a unittest file?

I have pycharm setup with a django project. I can run all django tests as django tests with the test runner.

I created a new test file, wrote a simple unittest on it. The tests run fine with manage.py and with the run configuration for running all tests.

But, when I try to run an individual test within the new test file from pycharm it fails because pycharm is trying to run it as a unittest instead of a django test. As shown in the screenshots below, pycharm considers this new file a unittest file, not a django test file. Yet both files are in the same directory (tests), both implement a class that extends Unittest, and both have tests.

enter image description here

enter image description here

enter image description here

enter image description here

I have the box below unchecked which is, not wrong?

enter image description here

Upvotes: 5

Views: 394

Answers (1)

Jose M Vidal
Jose M Vidal

Reputation: 9158

After a good night's sleep the solution became obvious.

The new testfile.py had

from unittest import TestCase

I changed that to

from django.test import TestCase

and now pycharm recognizes it as a python test file.

Upvotes: 6

Related Questions