a.jelly
a.jelly

Reputation: 91

Can't run django tests by tag

I have problem because I wanted to tag some test in django but when I type in console

from django.test import tag, TestCase


@tag('fast', 'something')
class SomeTestCase(TestCase):
    def setUp(self):
        # do something

    def test_something(self):
        # do something

when I type in console:

./manage.py test --tag=fast -k

I got:

Using existing test database for alias 'default'...
System check identified no issues (0 silenced).

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
Preserving test database for alias 'default'...

example module structure:

├── admin.py
├── __init__.py
├── migrations
├── models.py
├── tests
│   ├── __init__.py
│   ├── tests.py
│   └── test_views.py
├── urls.py
└── views.py

Upvotes: 9

Views: 3300

Answers (2)

Hybrid
Hybrid

Reputation: 596

Check if you have changed the TEST_RUNNER in your settings.py

We'd had django-nose installed. I didn't realize we were not using the default test runner and spent ages trying to figure out why my tags were not working. This post kept coming up when I was searching.

Upvotes: 1

Matt
Matt

Reputation: 3652

Check that there is not a syntax error or bad import in your test files. I had a bad import and it silently failed with Ran 0 tests in 0.000s.

Upvotes: 1

Related Questions