HassenPy / django-pdb

Gives you `manage.py runserver --pdb` and `manage.py test --pdb`
394 stars 61 forks source link

manage.py test broken on Python 2.6 with unittest2 installed #4

Closed ukch closed 12 years ago

ukch commented 12 years ago

Steps to reproduce:

The following traceback is generated:

Traceback (most recent call last):
  File "./manage.py", line 14, in <module>
    execute_manager(settings)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/__init__.py", line 67, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django_pdb-0.1.2-py2.6.egg/django_pdb/management/commands/test.py", line 2, in <module>
    from django_pdb.testrunners import PdbTestSuiteRunner
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django_pdb-0.1.2-py2.6.egg/django_pdb/testrunners.py", line 70, in <module>
    class PdbTestResult(ExceptionTestResultMixin, unittest._TextTestResult):
AttributeError: 'module' object has no attribute '_TextTestResult'

This can be fixed in one of two ways:

ukch commented 12 years ago

Apologies. I wrote this issue before looking at the code. The problem arises when unittest2 is installed - django does a from unittest2 import *, which doesn't import 'private' objects such as _TextTestResult. However, it would appear that TextTestResult and _TextTestResult are the same object, so this can probably be fixed by changing the call to use TextTestResult instead, unless you know of a good reason not to?

tomchristie commented 12 years ago

Fixed by https://github.com/tomchristie/django-pdb/commit/62388de031d4e330ef75629d79121c9d5b448999

Pushed to PyPI

Thanks!