Home > Software design >  How to run a single unit test in Django
How to run a single unit test in Django

Time:03-24

I run my tests with command "python3 manage.py test" it works fine, but it run all tests. When I try to run test by pushing a button "Run Test"(green triangle) there is an error:

Error
ImportError: Failed to import test module: app_shop
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 154, in loadTestsFromName
    module = __import__(module_name)
ModuleNotFoundError: No module named 'djcaching.app_shop'

How can I solve this problem?

My structure:

djcaching
  app_shop
    tests
  app_users
    tests
  djcaching
    settings

CodePudding user response:

to run single unit test run below command:

manage.py test <appname>.tests.<Testcasename>

you can also check the official documentation of unit test here

  • Related