How come unittest.TestCase doesn't exist for me?

Traceback (most recent call last):
  File "D:\My Projects\TAGEngine\TAGEngine\trunk\unittest.py", line 1, in <module>
    import unittest
  File "D:\My Projects\TAGEngine\TAGEngine\trunk\unittest.py", line 4, in <module>
    class CheckStructureAcceptance(unittest.TestCase):
AttributeError: 'module' object has no attribute 'TestCase'

???

Does yours outputs like this mate?

>>> import unittest
>>> dir (unittest)
['FunctionTestCase', 'TestCase', 'TestLoader', 'TestProgram', 'TestResult', 'TestSuite', 'TextTestRunner', '_CmpToKey', '_TextTestResult', '_WritelnDecorator', '__all__', '__author__', '__builtins__', '__doc__', '__email__', '__file__', '__metaclass__', '__name__', '__package__', '__unittest', '__version__', '_makeLoader', '_strclass', 'defaultTestLoader', 'findTestCases', 'getTestCaseNames', 'main', 'makeSuite', 'os', 'sys', 'time', 'traceback', 'types']
>>> print unittest.TestCase
<class 'unittest.TestCase'>

EDIT:

Mate change your script filename, it's replacing the module.

Cheers and Happy coding

Edited 6 Years Ago by Beat_Slayer: n/a

Mate change your script filename, it's replacing the module.

Your script named unittest.py, it's replacing the module file.

Cheers and Happy coding

Edited 6 Years Ago by Beat_Slayer: n/a

Already had similar problems, we try to keep the names neat, but as it adds the script path to the syspath, it replaces the modules if we have files with the same name.

It can be cool depending of the situations. :D

Cheers and Happy coding

Hi,
you can not define you filename as unittest which is LIB name...
this will make program search unittest.TestCase form you own file.
so if you rename your file.It's will be ok.

This question has already been answered. Start a new discussion instead.