Opened 11 years ago

Closed 10 years ago

#21671 closed Bug (fixed)

model_inheritance_same_model_name tests fail in isolation

Reported by: Aymeric Augustin Owned by: nobody
Component: Database layer (models, ORM) Version: 1.6
Severity: Normal Keywords:
Cc: anubhav9042@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

tests % ./runtests.py model_inheritance_same_model_name --settings=test_sqlite
Creating test database for alias 'default'...
Traceback (most recent call last):
  File "./runtests.py", line 359, in <module>
    options.failfast, args)
  File "./runtests.py", line 200, in django_tests
    test_labels or get_installed(), extra_tests=extra_tests)
  File "/Users/myk/Documents/dev/django/django/test/runner.py", line 145, in run_tests
    old_config = self.setup_databases()
  File "/Users/myk/Documents/dev/django/django/test/runner.py", line 107, in setup_databases
    return setup_databases(self.verbosity, self.interactive, **kwargs)
  File "/Users/myk/Documents/dev/django/django/test/runner.py", line 279, in setup_databases
    verbosity, autoclobber=not interactive)
  File "/Users/myk/Documents/dev/django/django/db/backends/creation.py", line 339, in create_test_db
    load_initial_data=False)
  File "/Users/myk/Documents/dev/django/django/core/management/__init__.py", line 159, in call_command
    return klass.execute(*args, **defaults)
  File "/Users/myk/Documents/dev/django/django/core/management/base.py", line 284, in execute
    self.validate()
  File "/Users/myk/Documents/dev/django/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:
model_inheritance_same_model_name.copy: 'title' has a relation with model <class 'model_inheritance.models.Title'>, which has either not been installed or is abstract.

This problem exists both in master and stable/1.6.x (I didn't check earlier versions).

The tests pass only when they're run in combination with the model_inheritance tests.

tests % ./runtests.py model_inheritance_same_model_name model_inheritance --settings=test_sqlite
Creating test database for alias 'default'...
Creating test database for alias 'other'...
........
----------------------------------------------------------------------
Ran 8 tests in 0.053s

OK
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...

It would be useful to fix this because it can create false positives when using the --bisect or --pair options of the test suite.

Attachments (1)

21671.diff (1.7 KB ) - added by Claude Paroz 11 years ago.
Skip when model_inheritance is not installed

Download all attachments as: .zip

Change History (6)

comment:1 by Tim Graham, 11 years ago

Triage Stage: UnreviewedAccepted

by Claude Paroz, 11 years ago

Attachment: 21671.diff added

Skip when model_inheritance is not installed

comment:2 by Claude Paroz, 11 years ago

Would it be acceptable that those tests are skipped when model_inheritance app is not tested/installed (as of attached patch)?

comment:3 by Aymeric Augustin, 10 years ago

That's a reasonable solution.

We have an API to tell if an application is installed in Django 1.7: https://docs.djangoproject.com/en/dev/ref/applications/#django.apps.apps.is_installed

comment:4 by ANUBHAV JOSHI, 10 years ago

Cc: anubhav9042@… added

comment:5 by Tim Graham, 10 years ago

Resolution: fixed
Status: newclosed

Fixed in #22402 (the model_inheritance_same_model_name app was consolidated into model_inheritance).

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