jezdez / django-discover-runner

A Django test runner based on unittest2's test discovery.
http://pypi.python.org/pypi/django-discover-runner
Other
132 stars 13 forks source link

TypeError: Item in ``from list'' not a string #9

Closed dbrgn closed 11 years ago

dbrgn commented 11 years ago

I'm using Django 1.5 on Python 2.7.

$ cat config/settings.py | grep TEST_
TEST_RUNNER = 'discover_runner.DiscoverRunner'
TEST_DISCOVER_TOP_LEVEL = PROJECT_ROOT
TEST_DISCOVER_ROOT = PROJECT_ROOT
TEST_DISCOVER_PATTERN = 'test*.py'

$ ./manage.py test
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/danilo/.virtualenvs/pcf/lib/python2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line
    utility.execute()
  File "/home/danilo/.virtualenvs/pcf/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/danilo/.virtualenvs/pcf/lib/python2.7/site-packages/django/core/management/commands/test.py", line 49, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/home/danilo/.virtualenvs/pcf/lib/python2.7/site-packages/django/core/management/base.py", line 218, in run_from_argv
    parser = self.create_parser(argv[0], argv[1])
  File "/home/danilo/.virtualenvs/pcf/lib/python2.7/site-packages/django/core/management/commands/test.py", line 52, in create_parser
    test_runner_class = get_runner(settings, self.test_runner)
  File "/home/danilo/.virtualenvs/pcf/lib/python2.7/site-packages/django/test/utils.py", line 129, in get_runner
    test_module = __import__(test_module_name, {}, {}, test_path[-1])
TypeError: Item in ``from list'' not a string

Using the normal Django test runner, everything works. Is this error related to django-discover-runner?

dbrgn commented 11 years ago

I also tried it with Django 1.4 and the same error occured... So it's probably an error on my side :/

dbrgn commented 11 years ago

I found the issue.

I have the unicode_literals future enabled in my settings.py, therefore test_path[-1] which gets passed to __import__ in django/test/utils.py is a unicode string and not a bytestring. This breaks the __import__ call.

I'll report it to the Django team.

posita commented 9 years ago

FYI, see also https://bugs.python.org/issue21720.