Opened 14 years ago

Closed 14 years ago

Last modified 12 years ago

#12640 closed (fixed)

Test execution order isn't exactly equal to the used before since r12255

Reported by: Ramiro Morales Owned by: nobody
Component: Testing framework Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This cause a failure in the model_package modeltest (it has a model defined in tests.py file, see #12245).

http://buildbot.djangoproject.com/builders/django-trunk%20ubuntu9.10-py2.6-sqlite/builds/162/steps/test/logs/stdio

File "/home/buildbot/slave-py2.6/parts/ubuntu9.10-py2.6-sqlite/django-trunk_ubuntu9.10-py2.6-sqlite/build/tests/modeltests/model_package/tests.py", line ?, in modeltests.model_package.tests.__test__.API_TESTS
Failed example:
    ad.save()
Exception raised:
    Traceback (most recent call last):
      File "/home/buildbot/slave-py2.6/parts/ubuntu9.10-py2.6-sqlite/django-trunk_ubuntu9.10-py2.6-sqlite/build/django/test/_doctest.py", line 1267, in __run
        compileflags, 1) in test.globs
      File "<doctest modeltests.model_package.tests.__test__.API_TESTS[18]>", line 1, in <module>
        ad.save()
      File "/home/buildbot/slave-py2.6/parts/ubuntu9.10-py2.6-sqlite/django-trunk_ubuntu9.10-py2.6-sqlite/build/django/db/models/base.py", line 430, in save
        self.save_base(using=using, force_insert=force_insert, force_update=force_update)
      File "/home/buildbot/slave-py2.6/parts/ubuntu9.10-py2.6-sqlite/django-trunk_ubuntu9.10-py2.6-sqlite/build/django/db/models/base.py", line 519, in save_base
        result = manager._insert(values, return_id=update_pk, using=using)
      File "/home/buildbot/slave-py2.6/parts/ubuntu9.10-py2.6-sqlite/django-trunk_ubuntu9.10-py2.6-sqlite/build/django/db/models/manager.py", line 197, in _insert
        return insert_query(self.model, values, **kwargs)
      File "/home/buildbot/slave-py2.6/parts/ubuntu9.10-py2.6-sqlite/django-trunk_ubuntu9.10-py2.6-sqlite/build/django/db/models/query.py", line 1345, in insert_query
        return query.get_compiler(using=using).execute_sql(return_id)
      File "/home/buildbot/slave-py2.6/parts/ubuntu9.10-py2.6-sqlite/django-trunk_ubuntu9.10-py2.6-sqlite/build/django/db/models/sql/compiler.py", line 730, in execute_sql
        cursor = super(SQLInsertCompiler, self).execute_sql(None)
      File "/home/buildbot/slave-py2.6/parts/ubuntu9.10-py2.6-sqlite/django-trunk_ubuntu9.10-py2.6-sqlite/build/django/db/models/sql/compiler.py", line 674, in execute_sql
        cursor.execute(sql, params)
      File "/home/buildbot/slave-py2.6/parts/ubuntu9.10-py2.6-sqlite/django-trunk_ubuntu9.10-py2.6-sqlite/build/django/db/backends/sqlite3/base.py", line 189, in execute
        return Database.Cursor.execute(self, query, params)
    OperationalError: no such table: model_package_advertisment

Problem is the test database creation step and the create test suite steps have their order exchanged when compared to how they were run before.

I guess this is because the suite building step populates the app cache and that allows models defined in tests.py to be picked and their DB table created.

Attachments (1)

12640.diff (2.2 KB ) - added by Ramiro Morales 14 years ago.

Download all attachments as: .zip

Change History (5)

by Ramiro Morales, 14 years ago

Attachment: 12640.diff added

comment:1 by Russell Keith-Magee, 14 years ago

Triage Stage: UnreviewedDesign decision needed

Hrm. I'm not sure of the right response is here.

You are correct that the order has changed - but it now matches what the documentation has said from the beginning.

Also, I'm not entirely convinced that the model_packages test isn't in error as written - allowing a model definition in tests.py isn't documented behavior as far as I am aware.

On a related ticket - #7835 exists as a ticket for adding 'test models'.

comment:2 by Russell Keith-Magee, 14 years ago

Triage Stage: Design decision neededAccepted

A closer read of Ramiro's patch points out that #12245 has already decided the 'test models' issue.

comment:3 by Russell Keith-Magee, 14 years ago

Resolution: fixed
Status: newclosed

(In [12261]) Fixed #12640 -- Corrected a regression in test suite construction order introduced by #12255. Also updated the docs to reflect what the test code has always done. Thanks to Ramiro Morales for the report and patch.

comment:4 by Jacob, 12 years ago

milestone: 1.2

Milestone 1.2 deleted

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