[Django] #30295: MaxLengthORMTests.test_custom_max_lengths test fails when run in isolation

7 views
Skip to first unread message

Django

unread,
Mar 27, 2019, 7:02:14 PM3/27/19
to django-...@googlegroups.com
#30295: MaxLengthORMTests.test_custom_max_lengths test fails when run in isolation
------------------------------------------------+------------------------
Reporter: Matt McDonald | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
------------------------------------------------+------------------------
Attempting to run tests from the `max_lengths` tests package results in
the following failure:

{{{
$ ./tests/runtests.py max_lengths --verbosity=2
Testing against Django installed in '/home/me/Development/django/django'
with up to 12 processes
Importing application max_lengths
Skipping setup of unused database(s): default, other.
System check identified no issues (0 silenced).
..E
======================================================================
ERROR: test_custom_max_lengths (max_lengths.tests.MaxLengthORMTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
yield
File "/usr/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/home/me/mmcdonald/Development/django/tests/max_lengths/tests.py",
line 38, in test_custom_max_lengths
p = PersonWithCustomMaxLengths.objects.create(**new_args)
File "/home/me/Development/django/django/db/models/manager.py", line 82,
in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/me/Development/django/django/db/models/query.py", line 421,
in create
obj.save(force_insert=True, using=self.db)
File "/home/me/Development/django/django/db/models/base.py", line 741,
in save
force_update=force_update, update_fields=update_fields)
File "/home/me/Development/django/django/db/models/base.py", line 779,
in save_base
force_update, using, update_fields,
File "/home/me/Development/django/django/db/models/base.py", line 870,
in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk,
raw)
File "/home/me/Development/django/django/db/models/base.py", line 908,
in _do_insert
using=using, raw=raw)
File "/home/me/Development/django/django/db/models/manager.py", line 82,
in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/me/Development/django/django/db/models/query.py", line 1175,
in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/home/me/Development/django/django/db/models/sql/compiler.py",
line 1316, in execute_sql
cursor.execute(sql, params)
File "/home/me/Development/django/django/db/backends/utils.py", line 67,
in execute
return self._execute_with_wrappers(sql, params, many=False,
executor=self._execute)
File "/home/me/Development/django/django/db/backends/utils.py", line 76,
in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/me/Development/django/django/db/backends/utils.py", line 84,
in _execute
return self.cursor.execute(sql, params)
File "/home/me/Development/django/django/db/utils.py", line 89, in
__exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/me/Development/django/django/db/backends/utils.py", line 84,
in _execute
return self.cursor.execute(sql, params)
File "/home/me/Development/django/django/db/backends/sqlite3/base.py",
line 391, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table:
max_lengths_personwithcustommaxlengths

----------------------------------------------------------------------
Ran 3 tests in 0.122s

FAILED (errors=1)
}}}

From a cursory glance, this appears to be a result of the
`max_lengths.tests.MaxLengthORMTests` class inappropriately extending from
`unittest.TestCase` when it should extend from `django.test.TestCase`, as
the `test_custom_max_lengths` method relies upon database and table
creation having been performed.

Interestingly, when executed as as part of a run of the full test suite,
the failure does not seem to occur. My guess would be that the test case
is being grouped into a suite with at least one other test case inheriting
from `django.test.TestCase`, which implicitly provides the database
initialization required by the `max_lengths` test instead of skipping the
db setup when the test is run in isolation.

https://github.com/django/django/blob/398afba084679f1055926f6f91bd33fe124a92c5/django/test/runner.py#L606

--
Ticket URL: <https://code.djangoproject.com/ticket/30295>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 27, 2019, 8:15:25 PM3/27/19
to django-...@googlegroups.com
#30295: MaxLengthORMTests.test_custom_max_lengths test fails when run in isolation
-------------------------------+------------------------------------

Reporter: Matt McDonald | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Tim Graham):

* type: Cleanup/optimization => Bug
* component: Uncategorized => Core (Other)
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/30295#comment:1>

Django

unread,
Mar 27, 2019, 9:51:18 PM3/27/19
to django-...@googlegroups.com
#30295: MaxLengthORMTests.test_custom_max_lengths test fails when run in isolation
-------------------------------+------------------------------------
Reporter: Matt McDonald | Owner: sage
Type: Bug | Status: assigned

Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by sage):

* owner: nobody => sage
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/30295#comment:2>

Django

unread,
Mar 28, 2019, 1:46:24 AM3/28/19
to django-...@googlegroups.com
#30295: MaxLengthORMTests.test_custom_max_lengths test fails when run in isolation
-------------------------------+------------------------------------
Reporter: Matt McDonald | Owner: sage
Type: Bug | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by sage):

[https://github.com/django/django/pull/11137 PR].

--
Ticket URL: <https://code.djangoproject.com/ticket/30295#comment:3>

Django

unread,
Mar 28, 2019, 1:46:44 AM3/28/19
to django-...@googlegroups.com
#30295: MaxLengthORMTests.test_custom_max_lengths test fails when run in isolation
-------------------------------+------------------------------------
Reporter: Matt McDonald | Owner: sage
Type: Bug | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by sage):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30295#comment:4>

Django

unread,
Mar 28, 2019, 5:19:23 AM3/28/19
to django-...@googlegroups.com
#30295: MaxLengthORMTests.test_custom_max_lengths test fails when run in isolation
-------------------------------+------------------------------------
Reporter: Matt McDonald | Owner: sage
Type: Bug | Status: closed

Component: Core (Other) | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"5a92bb0725e07068b260364ef66466f126000b0b" 5a92bb0]:
{{{
#!CommitTicketReference repository=""
revision="5a92bb0725e07068b260364ef66466f126000b0b"
Fixed #30295 -- Fixed max_lengths.tests.MaxLengthORMTests when run in
isolation.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30295#comment:5>

Django

unread,
Mar 28, 2019, 12:07:21 PM3/28/19
to django-...@googlegroups.com
#30295: MaxLengthORMTests.test_custom_max_lengths test fails when run in isolation
-------------------------------+------------------------------------
Reporter: Matt McDonald | Owner: sage
Type: Bug | Status: closed
Component: Core (Other) | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"4a6d3f258048b8ab9c9a4e51da56c273a77d114c" 4a6d3f25]:
{{{
#!CommitTicketReference repository=""
revision="4a6d3f258048b8ab9c9a4e51da56c273a77d114c"
[2.2.x] Fixed #30295 -- Fixed max_lengths.tests.MaxLengthORMTests when run
in isolation.

Backport of 5a92bb0725e07068b260364ef66466f126000b0b from master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30295#comment:6>

Reply all
Reply to author
Forward
0 new messages