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

nope. dir(unittest) lookse like this:

I shoulda posted that on the first post.

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.