2

Traceback:

./manage.py test my_app
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/zuber/projects/private-CR/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/home/zuber/projects/private-CR/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/zuber/projects/private-CR/env/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 30, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/home/zuber/projects/private-CR/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 381, in run_from_argv
    parser = self.create_parser(argv[0], argv[1])
  File "/home/zuber/projects/private-CR/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 354, in create_parser
    self.add_arguments(parser)
  File "/home/zuber/projects/private-CR/env/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 52, in add_arguments
    test_runner_class = get_runner(settings, self.test_runner)
  File "/home/zuber/projects/private-CR/env/local/lib/python2.7/site-packages/django/test/utils.py", line 152, in get_runner
    test_module = __import__(test_module_name, {}, {}, force_str(test_path[-1]))
ImportError: No module named simple

I tried to remove init.py from app folder and then I've got "No module named app_name". When I removed init.py from project folder - console said "No module named settings". How to test my app?

Vassily
  • 5,263
  • 4
  • 33
  • 63
  • 1
    why did you remove that? What reason? –  Aug 14 '15 at 14:12
  • http://stackoverflow.com/questions/21069880/running-django-tutorial-tests-fail-no-module-named-polls-tests - the only answer where the problem is close to mine – Vassily Aug 14 '15 at 14:20
  • The difference between your question and that one is that your folders are supposed to be modules, and his were not. – wpercy Aug 14 '15 at 14:22

3 Answers3

3

So first of all, you need to put your two __init__.pys back where you found them. They are what allow you to import things from that module. Secondly, you should post the code in manage.py so we have a better idea of what is going on, but it looks to me like you had a line in there that looks something like import django.contrib.admin.util or import <something> from django.contrib.admin.util. This module was removed in the release of django that you're using, so you should replace any occurrances of django.contrib.admin.util with django.contrib.admin.utils.

wpercy
  • 9,636
  • 4
  • 33
  • 45
  • #!/usr/bin/env python import os import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings") from django.core.management import execute_from_command_line execute_from_command_line(sys.argv) I've found only one django.contrib.admin.util in admin.py and replaced it with utils. But nothing's changed – Vassily Aug 14 '15 at 15:35
  • What file are you changing? `manage.py` or the file that you're trying to import from? You shouldn't be messing with the django source code unless you konw what you're doing... – wpercy Aug 14 '15 at 15:57
  • I didn't change django source code. I've just replaced admin.util with admin.utils in admin.py of my application. – Vassily Aug 15 '15 at 07:10
1

I resolved the problem by removing

TEST_RUNNER = 'django.test.simple.DjangoTestSuiteRunner'

from settings.py

see related question running all tests post django 1.6

Community
  • 1
  • 1
Vassily
  • 5,263
  • 4
  • 33
  • 63
0

For me while using Pycharm the problem was that the PyCharm test runner was not compatible with Django 2.0

The solution was: replace line 254:EOF with

  if VERSION[1] > 1 or VERSION[0] > 1:
    return DjangoTeamcityTestRunner(**options).run_tests(test_labels,
                                                         extra_tests=extra_tests, **options)

  return run_the_old_way(extra_tests, options, test_labels, verbosity)

Instead of:

  if VERSION[1] > 1:
    return DjangoTeamcityTestRunner(**options).run_tests(test_labels,
                                                         extra_tests=extra_tests, **options)

  return run_the_old_way(extra_tests, options, test_labels, verbosity)
Oleg Belousov
  • 9,981
  • 14
  • 72
  • 127