Test fails silently when using --tag

100 views
Skip to first unread message

Cammil Taank

unread,
Apr 4, 2021, 9:26:35 AM4/4/21
to django-d...@googlegroups.com
Hi All,

When I run tests using the --tag option, and there is a module level exception, the tests seem to pass without any errors.

Steps to reproduce:
1. Add this to tests:
from django.test import TestCase
from django.test import tag

assert 0                     

@tag('abc')
class TempTest(TestCase):

    def test_basic(self):
        self.assertFalse(True)


2. Run python manage.py test
This should fail as expected

3. Run python manage.py test --tag=abc
This for me passes without any error

Cammil

Adam Johnson

unread,
Apr 5, 2021, 5:18:45 AM4/5/21
to django-d...@googlegroups.com
Please don't report bugs here but to the ticket tracker. If you're not sure there's a bug, django-users, the forum, or IRC are the recommended venues.

That said, I cannot reproduce your problem. Using django's main branch, I started a new project with a tests.py file using your exact content and it errors on import as expected:

$ ./manage.py test --tag abc
System check identified no issues (0 silenced).
E
======================================================================
ERROR: example.core.tests (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: example.core.tests
Traceback (most recent call last):
  File "/.../python3.9/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/.../python3.9/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/.../example/core/tests.py", line 4, in <module>
    assert 0
AssertionError


----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CACc%3DA%3D1gOcps2ameDdo4qkDo64%3DcRB99SrbH%3DxrKx5XeSE%2Bk5Q%40mail.gmail.com.


--
Adam

Tim Graham

unread,
Apr 5, 2021, 8:28:45 AM4/5/21
to Django developers (Contributions to Django itself)
This was fixed a week ago (will be in Django 4.0). https://code.djangoproject.com/ticket/29127

Adam Johnson

unread,
Apr 5, 2021, 9:04:09 AM4/5/21
to django-d...@googlegroups.com
Great, thanks Tim.

--
Adam

Cammil Taank

unread,
Apr 5, 2021, 12:37:52 PM4/5/21
to django-d...@googlegroups.com

Santlalkewat Kewat

unread,
Apr 6, 2021, 9:02:46 AM4/6/21
to django-d...@googlegroups.com

Santlal...@gmail.com


--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages