AttributeError: 'module' object has no attribute 'tests'

后端 未结 11 1853
自闭症患者
自闭症患者 2020-12-04 14:43

I\'m running this command:

python manage.py test project.apps.app1.tests

and it causes this error:

AttributeError: \

11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 15:41

    I finally figured it out working on another problem. The problem was that my test couldn't find an import.

    It looks like you get the above error if your test fails to import. This makes sense because the test suite can't import a broken test. At least I think this is what is going on because I fixed the import within my test file and sure enough it started working.

    To validate your test case just try import the test case file in python console.

    Example:

    from project.apps.app1.tests import *
    

提交回复
热议问题