Create an app with python manage.py startapp sample and the test described in sample / tests.py will work.
Although I created the sample / tests / directory and sample / tests / test_model.py to split the files,
python manage.py test doesn't work.
(venv) user@localhost:django-app $ python manage.py test
System check identified no issues (0 silenced).
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
Django's tests have ** rules to get test runners to discover them **. I checked if it was aligned correctly.
--Does the test module name (file name) start with test ... ** OK **
――Do you inherit django.test.TestCase? ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ** OK **
(ʻUnittest.case.Testcaseis also OK) --Does the test method name start withtest? ・ ・ ・ ・ ・ ・ ・ ・ ・ ・ ** OK ** --In the first place, is it described in ʻINSTALLED_APPS of settings.py ... ** OK **
The cause was that __init__.py did not exist in thesample / tests /directory.
It looks like we need to make Django aware of it as a module.
An empty file is fine, so if you create it, it will work.
Recommended Posts