[Django] #32994: Invoking runtests with a CLI prelude causes utils_tests failures

14 views
Skip to first unread message

Django

unread,
Aug 6, 2021, 6:06:36 AM8/6/21
to django-...@googlegroups.com
#32994: Invoking runtests with a CLI prelude causes utils_tests failures
------------------------------------------------+------------------------
Reporter: Keryn Knight | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
It may not be worth fixing, for all that it's somewhat obvious what has
happened, but running:
{{{
python -m cProfile --sort=time runtests.py
}}}
causes the following failures:
{{{
======================================================================
FAIL: test_manage_py
(utils_tests.test_autoreload.RestartWithReloaderTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/kez/Code/django/tests/utils_tests/test_autoreload.py", line
480, in test_manage_py
self.assertEqual(
AssertionError: Lists differ: ['/us[20 chars]l', '-m', 'cProfile',
'runserver'] != ['/us[20 chars]l',
'/var/folders/rv/jpsxqc0x5ks0_8jtn67b5psw0[55 chars]ver']

First differing element 2:
'-m'
'/var/folders/rv/jpsxqc0x5ks0_8jtn67b5psw0[41 chars]e.py'

First list contains 1 additional elements.
First extra element 4:
'runserver'

- ['/usr/bin/python', '-Wall', '-m', 'cProfile', 'runserver']
+ ['/usr/bin/python',
+ '-Wall',
+
'/var/folders/rv/jpsxqc0x5ks0_8jtn67b5psw0000gn/T/django_y2ubxvqz/tmp5ruspi9z/manage.py',
+ 'runserver']
}}}
{{{
======================================================================
FAIL: test_entrypoint_fallback
(utils_tests.test_autoreload.TestChildArguments)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/Users/kez/.asdf/installs/python/3.9.5/lib/python3.9/unittest/mock.py",
line 1337, in patched
return func(*newargs, **newkeywargs)
File "/Users/kez/Code/django/tests/utils_tests/test_autoreload.py", line
219, in test_entrypoint_fallback
self.assertEqual(
AssertionError: Lists differ: ['/Us[49 chars]on', '-m', 'cProfile',
'runserver'] != ['/Us[49 chars]on',
PosixPath('/var/folders/rv/jpsxqc0x5ks0_8[80 chars]ver']

First differing element 1:
'-m'
PosixPath('/var/folders/rv/jpsxqc0x5ks0_8[66 chars].py')

First list contains 1 additional elements.
First extra element 3:
'runserver'

['/Users/kez/Code/django/.direnv/python-3.9.5/bin/python',
+
PosixPath('/var/folders/rv/jpsxqc0x5ks0_8jtn67b5psw0000gn/T/django_y2ubxvqz/tmpqd44gzim
/django-admin-script.py'),
- '-m',
- 'cProfile',
'runserver']
}}}
{{{
======================================================================
FAIL: test_exe_fallback (utils_tests.test_autoreload.TestChildArguments)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/Users/kez/.asdf/installs/python/3.9.5/lib/python3.9/unittest/mock.py",
line 1337, in patched
return func(*newargs, **newkeywargs)
File "/Users/kez/Code/django/tests/utils_tests/test_autoreload.py", line
208, in test_exe_fallback
self.assertEqual(
AssertionError: Lists differ:
['/Users/kez/Code/django/.direnv/python-3.[42 chars]ver'] !=
[PosixPath('/var/folders/rv/jpsxqc0x5ks0_8[74 chars]ver']

First differing element 0:
'/Users/kez/Code/django/.direnv/python-3.9.5/bin/python'
PosixPath('/var/folders/rv/jpsxqc0x5ks0_8[60 chars]exe')

First list contains 2 additional elements.
First extra element 2:
'cProfile'

+
[PosixPath('/var/folders/rv/jpsxqc0x5ks0_8jtn67b5psw0000gn/T/django_y2ubxvqz/tmpjbmy1tyg
/django-admin.exe'),
- ['/Users/kez/Code/django/.direnv/python-3.9.5/bin/python',
- '-m',
- 'cProfile',
'runserver']
}}}
{{{
======================================================================
FAIL: test_raises_runtimeerror
(utils_tests.test_autoreload.TestChildArguments)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/Users/kez/.asdf/installs/python/3.9.5/lib/python3.9/unittest/mock.py",
line 1337, in patched
return func(*newargs, **newkeywargs)
File "/Users/kez/Code/django/tests/utils_tests/test_autoreload.py", line
229, in test_raises_runtimeerror
autoreload.get_child_arguments()
File
"/Users/kez/.asdf/installs/python/3.9.5/lib/python3.9/contextlib.py", line
124, in __exit__
next(self.gen)
File "/Users/kez/Code/django/django/test/testcases.py", line 686, in
_assert_raises_or_warns_cm
yield cm
AssertionError: RuntimeError not raised
}}}
{{{
======================================================================
FAIL: test_warnoptions (utils_tests.test_autoreload.TestChildArguments)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/Users/kez/.asdf/installs/python/3.9.5/lib/python3.9/unittest/mock.py",
line 1337, in patched
return func(*newargs, **newkeywargs)
File "/Users/kez/Code/django/tests/utils_tests/test_autoreload.py", line
197, in test_warnoptions
self.assertEqual(
AssertionError: Lists differ: ['/Us[61 chars]r', '-m', 'cProfile',
'runserver'] != ['/Us[61 chars]r',
'/Users/kez/Code/django/tests/utils_tests/[28 chars]ver']

First differing element 2:
'-m'
'/Users/kez/Code/django/tests/utils_tests/test_autoreload.py'

First list contains 1 additional elements.
First extra element 4:
'runserver'

['/Users/kez/Code/django/.direnv/python-3.9.5/bin/python',
'-Werror',
+ '/Users/kez/Code/django/tests/utils_tests/test_autoreload.py',
- '-m',
- 'cProfile',
'runserver']
}}}

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

Django

unread,
Aug 6, 2021, 6:46:10 AM8/6/21
to django-...@googlegroups.com
#32994: Invoking runtests with a CLI prelude causes utils_tests failures
--------------------------------------+------------------------------------

Reporter: Keryn Knight | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Core (Other) | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

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

* component: Testing framework => Core (Other)
* stage: Unreviewed => Accepted


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

Django

unread,
Aug 8, 2021, 10:07:01 AM8/8/21
to django-...@googlegroups.com
#32994: Invoking runtests with a CLI prelude causes utils_tests failures
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Jonny
Type: | Park
Cleanup/optimization | Status: assigned

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

* owner: nobody => Jonny Park
* status: new => assigned


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

Django

unread,
Aug 15, 2021, 12:34:48 PM8/15/21
to django-...@googlegroups.com
#32994: Invoking runtests with a CLI prelude causes utils_tests failures
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Jonny
Type: | Park
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Jonny Park):

Tests in description assumes `__main__.__spec__` value to be `None`, but
running the test with `-m` option make some change in `__main__.__spec__`
thus gives unexpected result. I fixed the issue by mocking
`__main__.__spec__` and did a pull request at

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

Django

unread,
Aug 15, 2021, 2:25:55 PM8/15/21
to django-...@googlegroups.com
#32994: Invoking runtests with a CLI prelude causes utils_tests failures
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Jonny
Type: | Park
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* has_patch: 0 => 1


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

Django

unread,
Aug 19, 2021, 3:23:22 AM8/19/21
to django-...@googlegroups.com
#32994: Invoking runtests with a CLI prelude causes utils_tests failures
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Jonny
Type: | Park
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

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

* stage: Accepted => Ready for checkin


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

Django

unread,
Aug 19, 2021, 3:50:03 AM8/19/21
to django-...@googlegroups.com
#32994: Invoking runtests with a CLI prelude causes utils_tests failures
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Jonny
Type: | Park
Cleanup/optimization | Status: closed

Component: Core (Other) | Version: dev
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

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

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


Comment:

In [changeset:"4e8121e8e42a24acc3565851c9ef50ca8322b15c" 4e8121e8]:
{{{
#!CommitTicketReference repository=""
revision="4e8121e8e42a24acc3565851c9ef50ca8322b15c"
Fixed #32994 -- Fixed autoreloader tests when using 'python -m'.
}}}

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

Reply all
Reply to author
Forward
0 new messages