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
With Django’s test-execution framework and assorted utilities, you can simulate requests, insert test data, inspect your application’s output and generally verify your code is doing what it should be doing. The preferred way to write tests in Django is using the unittest module built-in to the Python standard library.
You can also use any other Python test framework; Django provides an API and tools for that kind of integration. They are described in the Using different testing frameworks section of Advanced testing topics.
Django provides a test framework with a small hierarchy of classes that build on the Python standard unittest library. Despite the name, this test framework is suitable for both unit and integration tests. The Django framework adds API methods and tools to help test web and Django-specific behavior.
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
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With