--
Ticket URL: <https://code.djangoproject.com/ticket/29127>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
Ticket URL: <https://code.djangoproject.com/ticket/29127#comment:1>
* 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>
* owner: nobody => Daniel Hones
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/29127#comment:3>
* 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>
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>
* owner: (none) => Chris Jerdonek
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/29127#comment:6>
* has_patch: 0 => 1
Comment:
PR: https://github.com/django/django/pull/14195
--
Ticket URL: <https://code.djangoproject.com/ticket/29127#comment:7>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/29127#comment:8>
* 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>