Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

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

7histle opened this Issue Nov 14, 2012 · 3 comments


None yet
4 participants

7histle commented Nov 14, 2012

7histle@swamp:~/wrk$ uname -a
Linux swamp 3.2.0-32-generic #51-Ubuntu SMP Wed Sep 26 21:32:50 UTC 2012 i686 i686 i386 GNU/Linux
7histle@swamp:~$ ipython --version
7histle@swamp:~$ cd /usr/local/lib/python2.7/dist-packages/django/utils
7histle@swamp:/usr/local/lib/python2.7/dist-packages/django/utils$ ipython
Traceback (most recent call last):
  File "/usr/bin/ipython", line 8, in <module>
  File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/ipapp.py", line 402, in launch_new_instance
  File "<string>", line 2, in initialize
  File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 84, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/ipapp.py", line 312, in initialize
  File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/ipapp.py", line 332, in init_shell
  File "/usr/lib/python2.7/dist-packages/IPython/config/configurable.py", line 318, in instance
    inst = cls(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/interactiveshell.py", line 183, in __init__
    user_module=user_module, custom_exceptions=custom_exceptions
  File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 478, in __init__
  File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 662, in init_reload_doctest
  File "/usr/lib/python2.7/dist-packages/IPython/utils/doctestreload.py", line 72, in doctest_reload
    import doctest
  File "/usr/lib/python2.7/doctest.py", line 2153, in <module>
    class DocTestCase(unittest.TestCase):
AttributeError: 'module' object has no attribute 'TestCase'

If you suspect this is an IPython bug, please report it at:
or send an email to the mailing list at ipython-dev@scipy.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:


but if ....

7histle@swamp:/usr/local/lib/python2.7/dist-packages/django/utils$ cd
7histle@swamp:~$ ipython
Python 2.7.3 (default, Aug  1 2012, 05:16:07) 
Type "copyright", "credits" or "license" for more information.

IPython 0.12.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: 

All ok


Carreau commented Nov 14, 2012

Could it be that django/utils contain a folder unittest that is imported instead of Python unit testing framework ?


bfroehle commented Nov 14, 2012

Yes, this is an unavoidable artifact of Python's import mechanism. The unittest module in your current directory is shadowing the system unittest module. There's nothing we can do here, unfortunately.

@bfroehle bfroehle closed this Nov 14, 2012


Carreau commented Nov 14, 2012

Ah, true, note for myself, you do not need to clone a github repo to browse it..

@minrk minrk added this to the no action milestone Mar 26, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment