1

I'm running tests with nose and would like to take advantage of the --failed flag. But as soon as I add it I get errors like these for user related models:

./manage.py test  # works
./manage.py test --failed # fails

CommandError: One or more models did not validate:
vod.video: 'user' has a relation with model accounts.CustomUser, which has either not been installed or is abstract.

Packages:

Django==1.6.7
django-nose==1.3
nose==1.3.4

What am I doing wrong?

Update: I don't see the issue on my master branch. In the new branch I'm started to use the TenantTestCase class from django-tenant-schemas. May be the cause of the problem.

The traceback I get:

./manage.py test --failed --traceback
nosetests --failed --verbosity=1
Creating test database for alias 'default'...
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/dev/envs/py26/lib/python2.6/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/home/dev/envs/py26/lib/python2.6/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/dev/envs/py26/lib/python2.6/site-packages/django/core/management/commands/test.py", line 50, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/home/dev/envs/py26/lib/python2.6/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/dev/envs/py26/lib/python2.6/site-packages/django/core/management/commands/test.py", line 71, in execute
    super(Command, self).execute(*args, **options)
  File "/home/dev/envs/py26/lib/python2.6/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/home/dev/envs/py26/lib/python2.6/site-packages/south/management/commands/test.py", line 8, in handle
    super(Command, self).handle(*args, **kwargs)
  File "/home/dev/envs/py26/lib/python2.6/site-packages/django/core/management/commands/test.py", line 88, in handle
    failures = test_runner.run_tests(test_labels)
  File "/home/dev/envs/py26/lib/python2.6/site-packages/django_nose/runner.py", line 218, in run_tests
    result = self.run_suite(nose_argv)
  File "/home/dev/envs/py26/lib/python2.6/site-packages/django_nose/runner.py", line 165, in run_suite
    addplugins=plugins_to_add)
  File "/home/dev/envs/py26/lib/python2.6/site-packages/nose/core.py", line 121, in __init__
    **extra_args)
  File "/usr/lib/python2.6/unittest.py", line 817, in __init__
    self.runTests()
  File "/home/dev/envs/py26/lib/python2.6/site-packages/nose/core.py", line 207, in runTests
    result = self.testRunner.run(self.test)
  File "/home/dev/envs/py26/lib/python2.6/site-packages/nose/core.py", line 50, in run
    wrapper = self.config.plugins.prepareTest(test)
  File "/home/dev/envs/py26/lib/python2.6/site-packages/nose/plugins/manager.py", line 99, in __call__
    return self.call(*arg, **kw)
  File "/home/dev/envs/py26/lib/python2.6/site-packages/nose/plugins/manager.py", line 167, in simple
    result = meth(*arg, **kw)
  File "/home/dev/envs/py26/lib/python2.6/site-packages/django_nose/plugin.py", line 76, in prepareTest
    self.old_names = self.runner.setup_databases()
  File "/home/dev/envs/py26/lib/python2.6/site-packages/django_nose/runner.py", line 401, in setup_databases
    return super(NoseTestSuiteRunner, self).setup_databases()
  File "/home/dev/envs/py26/lib/python2.6/site-packages/django/test/runner.py", line 107, in setup_databases
    return setup_databases(self.verbosity, self.interactive, **kwargs)
  File "/home/dev/envs/py26/lib/python2.6/site-packages/django/test/runner.py", line 279, in setup_databases
    verbosity, autoclobber=not interactive)
  File "/home/dev/envs/py26/lib/python2.6/site-packages/django/db/backends/creation.py", line 339, in create_test_db
    load_initial_data=False)
  File "/home/dev/envs/py26/lib/python2.6/site-packages/django/core/management/__init__.py", line 159, in call_command
    return klass.execute(*args, **defaults)
  File "/home/dev/envs/py26/lib/python2.6/site-packages/django/core/management/base.py", line 284, in execute
    self.validate()
  File "/home/dev/envs/py26/lib/python2.6/site-packages/django/core/management/base.py", line 314, in validate
    raise CommandError("One or more models did not validate:\n%s" % error_text)
django.core.management.base.CommandError: One or more models did not validate:
vod.video: 'user' has a relation with model accounts.CustomUser, which has either not been installed or is abstract.
djangonaut
  • 7,233
  • 5
  • 37
  • 52
  • Could be test logic-specific. Have you noticed if the problem persists if different tests are failing? Thanks. – alecxe Jan 21 '15 at 07:00
  • @alecxe, I'm progressing through broken test cases but the problem persists so far. – djangonaut Jan 22 '15 at 00:11
  • Thanks. My point is that I doubt `--failed` is really a culprit of the problem. It is just a failing test, or may be an order in which tests are executed. Could you show the complete error traceback? – alecxe Jan 22 '15 at 02:24
  • @alecxe Thanks a lot for your help, I also don't think it's a problem with nose but have a hard time finding the issue. I added the traceback. – djangonaut Jan 22 '15 at 03:54

1 Answers1

0

I think it has to do with the custom user model. Check this out https://github.com/bernardopires/django-tenant-schemas/issues/237

Tony
  • 103
  • 1
  • 1
  • 4
  • While this may theoretically answer the question, [it would be preferable](http://meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – ryanyuyu Mar 13 '15 at 18:10