Reputation: 2791
I am using Django 2.1.5 and pycharm. When running tests from Pycharm I started getting this error:
File "/Users/..../lib/python3.6/site-packages/nose/loader.py", line 576, in _makeTest
if issubclass(parent, unittest.TestCase):
TypeError: issubclass() arg 1 must be a class
I'm getting it only when trying to run one test (and not a test class). Also getting it when trying to run it through
python manage.py test specific_test
I understand the error meaning, but I don't understand why I started getting it suddenly.
EDIT:
Full traceback:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
yield
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/..../lib/python3.6/site-packages/nose/failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "/..../lib/python3.6/site-
packages/nose/loader.py", line 523, in makeTest
return self._makeTest(obj, parent)
File "/..../lib/python3.6/site-packages/nose/loader.py", line 576, in _makeTest
if issubclass(parent, unittest.TestCase):
TypeError: issubclass() arg 1 must be a class
the parent is
<function MyTestClass.test_function at 0x10ff32f28>
Upvotes: 3
Views: 3362
Reputation: 1212
To fix this in Pycharm, you need to specify your test runner with TEST_RUNNER = "django_nose.NoseTestSuiteRunner"
(or whatever your runner) in the settings.py
you set up in Preferences > Languages & Frameworks > Django
and NOT the one set up in your test/run config.
See comments on the following:
Upvotes: 0
Reputation: 10382
I get this error when I don't properly point to the test I'm trying to run.
When I tried to run a specific test method I tried the following and got the error you mention: ./manage.py test myapp.tests.test_file.MyTestCase.test_something
What I had to run to actually get it to work was: ./manage.py test myapp.tests.test_file:MyTestCase.test_something
(Notice the :
between the file name and the class name)
I believe this issue is specific to 'nose'.
Upvotes: 4