AttributeError: 'module' object has no attribute 'TestCase' AttributeError: 'module' object has no attribute 'TestCase' python python

AttributeError: 'module' object has no attribute 'TestCase'


You have a local file named unittest.py that is being imported instead:

/home/mariusz/Pulpit/unittest.py

Rename that file or remove it altogether. Make sure you remove any corresponding unittest.pyc file in the same folder if it is there.

The file is masking the standard library package.


Your script named unittest.py is replacing the module file.Rename your unittest.py script to something else.


In my case, one of the dependency was not there.

import osfrom some_package import some_module

the some_module was not there in python(python couldn't import it). Once I commented the import statement python started discovering my test cases.

python -m unittest tests.test_my_own_module