[Django] #29127: manage.py executting tagged tests with syntax error does not show them

4 views
Skip to first unread message

Django

unread,
Feb 12, 2018, 11:19:34 AM2/12/18
to django-...@googlegroups.com
#29127: manage.py executting tagged tests with syntax error does not show them
-------------------------------------+-------------------------------------
Reporter: Kryštof | Owner: nobody
Řeháček |
Type: Bug | Status: new
Component: Testing | Version: 2.0
framework | Keywords: tests, tagged-
Severity: Normal | tests, SyntaxError
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
When I execute tests with syntax error without any argument then it shows
`SyntaxError: invalid syntax` as expected but when I execute tagged tests,
then it shows that it ran 0 tests and it is OK and even error. So when
tests with syntax executed with the --tag="some_tag" argument and they
have syntax error then they complete with OK status.

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

Django

unread,
Feb 12, 2018, 11:48:31 AM2/12/18
to django-...@googlegroups.com
#29127: manage.py executing tagged tests with syntax error does not show them
-------------------------------------+-------------------------------------
Reporter: Kryštof Řeháček | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 2.0
Severity: Normal | Resolution:
Keywords: tests, tagged- | Triage Stage:
tests, SyntaxError | Unreviewed
Has patch: 0 | Needs documentation: 0

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

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

Django

unread,
Feb 12, 2018, 1:22:18 PM2/12/18
to django-...@googlegroups.com
#29127: Running tagged tests hides any with syntax errors

-------------------------------------+-------------------------------------
Reporter: Kryštof Řeháček | Owner: nobody
Type: Bug | Status: new

Component: Testing framework | Version: 2.0
Severity: Normal | Resolution:
Keywords: tests, tagged- | Triage Stage: Accepted
tests, SyntaxError |
Has patch: 0 | Needs documentation: 0

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

* stage: Unreviewed => Accepted


Comment:

The problem may be in `django.test.runner.filter_tests_by_tags()`.

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

Django

unread,
Feb 18, 2018, 12:23:56 AM2/18/18
to django-...@googlegroups.com
#29127: Running tagged tests hides any with syntax errors
-------------------------------------+-------------------------------------
Reporter: Kryštof Řeháček | Owner: Daniel
| Hones
Type: Bug | Status: assigned

Component: Testing framework | Version: 2.0
Severity: Normal | Resolution:
Keywords: tests, tagged- | Triage Stage: Accepted
tests, SyntaxError |
Has patch: 0 | Needs documentation: 0

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

* owner: nobody => Daniel Hones
* status: new => assigned


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

Django

unread,
Feb 18, 2018, 1:32:09 AM2/18/18
to django-...@googlegroups.com
#29127: Running tagged tests hides any with syntax errors
-------------------------------------+-------------------------------------
Reporter: Kryštof Řeháček | Owner: (none)
Type: Bug | Status: new

Component: Testing framework | Version: 2.0
Severity: Normal | Resolution:
Keywords: tests, tagged- | Triage Stage: Accepted
tests, SyntaxError |
Has patch: 0 | Needs documentation: 0

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

* status: assigned => new
* owner: Daniel Hones => (none)


Comment:

It looks like this behavior is ultimately due to Python's unittest
TestLoader and not Django's test framework. In case of a SyntaxError when
loading a test suite, it hits
[https://github.com/python/cpython/blob/master/Lib/unittest/loader.py#L439
this line], which creates a _FailedTest object from it without raising an
error. Then the {{{django.test.runner.filter_tests_by_tags()}}} sees a
_FailedTest object which won't have any tags and so it won't be run at
all. Since tests are tagged using a decorator, tests in a file with a
syntax error won't have any tags recognized for them anyway because the
file cannot be evaluated. I don't think there's a reasonable fix for this
and I'm not sure it should even be considered a bug, although the behavior
is a bit misleading.

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

Django

unread,
Mar 24, 2021, 4:31:32 PM3/24/21
to django-...@googlegroups.com
#29127: Running tagged tests hides any with syntax errors
-------------------------------------+-------------------------------------
Reporter: Kryštof Řeháček | Owner: (none)
Type: Bug | Status: new

Component: Testing framework | Version: 2.0
Severity: Normal | Resolution:
Keywords: tests, tagged- | Triage Stage: Accepted
tests, SyntaxError |
Has patch: 0 | Needs documentation: 0

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

Comment (by Chris Jerdonek):

I think a possible solution for this would be to make it so that
`unittest.loader._FailedTest` objects always match when tags are provided.
That would prevent the issue of tests falsely passing due to e.g. syntax
errors.

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

Django

unread,
Mar 26, 2021, 6:29:00 AM3/26/21
to django-...@googlegroups.com
#29127: Running tagged tests hides any with syntax errors
-------------------------------------+-------------------------------------
Reporter: Kryštof Řeháček | Owner: Chris
| Jerdonek
Type: Bug | Status: assigned

Component: Testing framework | Version: 2.0
Severity: Normal | Resolution:
Keywords: tests, tagged- | Triage Stage: Accepted
tests, SyntaxError |
Has patch: 0 | Needs documentation: 0

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

* owner: (none) => Chris Jerdonek


* status: new => assigned


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

Django

unread,
Mar 27, 2021, 5:01:28 AM3/27/21
to django-...@googlegroups.com
#29127: Running tagged tests hides any with syntax errors
-------------------------------------+-------------------------------------
Reporter: Kryštof Řeháček | Owner: Chris
| Jerdonek
Type: Bug | Status: assigned
Component: Testing framework | Version: 2.0
Severity: Normal | Resolution:
Keywords: tests, tagged- | Triage Stage: Accepted
tests, SyntaxError |
Has patch: 1 | Needs documentation: 0

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

* has_patch: 0 => 1


Comment:

PR: https://github.com/django/django/pull/14195

--
Ticket URL: <https://code.djangoproject.com/ticket/29127#comment:7>

Django

unread,
Mar 29, 2021, 1:38:04 AM3/29/21
to django-...@googlegroups.com
#29127: Running tagged tests hides any with syntax errors
-------------------------------------+-------------------------------------
Reporter: Kryštof Řeháček | Owner: Chris
| Jerdonek
Type: Bug | Status: assigned
Component: Testing framework | Version: 2.0
Severity: Normal | Resolution:
Keywords: tests, tagged- | Triage Stage: Ready for
tests, SyntaxError | 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/29127#comment:8>

Django

unread,
Mar 30, 2021, 4:47:59 AM3/30/21
to django-...@googlegroups.com
#29127: Running tagged tests hides any with syntax errors
-------------------------------------+-------------------------------------
Reporter: Kryštof Řeháček | Owner: Chris
| Jerdonek
Type: Bug | Status: closed

Component: Testing framework | Version: 2.0
Severity: Normal | Resolution: fixed

Keywords: tests, tagged- | Triage Stage: Ready for
tests, SyntaxError | 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:"038940cf5525c41464a1b9e9ba3801042320b0cc" 038940cf]:
{{{
#!CommitTicketReference repository=""
revision="038940cf5525c41464a1b9e9ba3801042320b0cc"
Fixed #29127 -- Prevented DiscoverRunner from hiding tagged test with
syntax errors.

This mades _FailedTest objects always match tags in DiscoverRunner.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29127#comment:9>

Reply all
Reply to author
Forward
0 new messages