How do I tell django-nose where my tests are?

后端 未结 5 1628
小鲜肉
小鲜肉 2021-02-02 15:38

I have my tests for a Django application in a tests directory:

my_project/apps/my_app/
├── __init__.py
├── tests
│   ├── __init__.py
│   ├── field_tests.py
│   └         


        
5条回答
  •  隐瞒了意图╮
    2021-02-02 16:01

    To make nose realize where your apps are add these to the top of manage.py

    import os, site
    
    ROOT = os.path.dirname(os.path.abspath(__file__))
    path = lambda *a: os.path.join(ROOT, *a)
    site.addsitedir(path('apps'))
    

    Since then you can use

    python manage.py test my_app.tests.storage_tests:TestCase.test_name

提交回复
热议问题