Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#16388 closed Bug (needsinfo)

django unittest bug

Reported by: freewave@… Owned by: nobody
Component: Testing framework Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Aymeric Augustin)

enviroment: python2.7 + django1.3
with the steps below:

  • 1 django-admin.py startproject myapp
  • 2 cd myapp
  • 3 manage.py startapp foo
  • 4 manage.py test

error occurs:

File "C:\Python27\lib\site-packages\django\test\simple.py", line 237, in setup_test_environment
	unittest.installHandler()
AttributeError:'module' object has no attribute 'installHandler'

problem?:
the file “site-packages\django\utils\unittest” contains the code

try:
    # check the system path first
    from unittest2 import *
except ImportError:
    if sys.version_info >= (2,7):
        # unittest2 features are native in Python 2.7
        from unittest import *
    else:
        ...

but unittest2 features are native in Python 2.7?

Change History (4)

comment:1 by Bernhard Essl, 13 years ago

I can't reproduce this error on my Windows XP virtual machine.

comment:2 by Aymeric Augustin, 13 years ago

Description: modified (diff)

Fixed formatting, just to be able to read the bug report — please use the preview before submitting a bug.

comment:3 by Aymeric Augustin, 13 years ago

Resolution: needsinfo
Status: newclosed

It looks like there's an obsolete or invalid version of unittest2 installed on your machine. Can you determine which version of unittest is actually loaded by Django?

For instance, in ./manage.py shell, what's the output of:

>>> import unittest2
>>> unittest2.__file__
>>> unittest2.__version__
>>> import unittest
>>> unittest.__file__
>>> unittest.__version__
>>> from django.utils import unittest
>>> unittest.__version__

comment:4 by freewave@…, 13 years ago

Sorry!
My prev python version is "Python 2.7a1 (r27a1:76691, Dec 6 2009, 19:41:06) on win32". The problem exists in this version.
Problem is gone when I reinstall python "Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32".

Note: See TracTickets for help on using tickets.
Back to Top