pycharm generates wrong target path for tests

Viewed 1224

using Pycharm 2017.1.3 (but saw it in other versions as well) - When running single test (right click the test and run), the test target configuration that automatically created is wrong - before the class name it puts dot (.) instead of colon(:), so it looks like it's a function. For that reason, when running the single test, I'm getting this error:

Traceback (most recent call last):
File "/Users/...../python3.6/site- 
packages/nose/failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "/Users/...../python3.6/site- 
packages/nose/loader.py", line 523, in makeTest
return self._makeTest(obj, parent)
File "/Users/...../python3.6/site- 
packages/nose/loader.py", line 576, in _makeTest
if issubclass(parent, unittest.TestCase):
TypeError: issubclass() arg 1 must be a class

for example, this target:

myproject.utils.tests.test_integration.MyNewService.test_use_case

should be:

myproject.utils.tests.test_integration:MyNewService.test_use_case
2 Answers

After investigation, the problem appears to be a custom settings.py file name.

PyCharm won't automatically discover it, so it needs to be configured manually in

Preferences | Languages & Frameworks | Django | Settings

Related