这是一种不寻常的情况 - 大多数Django用户都希望Django的测试运行者能够找到他们所有的测试。如何禁用Django的测试发现?
我正在研究一个Python库,其中包含多个运行不同配置的测试套件,所以我不想让发现从错误配置中找到并运行测试。如何完全禁用发现,并依赖仅在INSTALLED_APPS中显式声明的应用程序运行测试的1.6版之前的行为?
我的图书馆结构:
library/ # django app used by others
tests/ # custom test suites here
core/ # tests of core functionality
custom/ # tests of a custom feature requiring separate config
contrib/ # tests for assorted contrib features, also requiring separate config
manage_core.py # separate manage.py files for each "project"
manage_custom.py # these specify settings file to use.
manage_contrib.py
settings.py # base settings for all tests
settings_core.py # settings for 'core' tests including unique INSTALLED_APPS
settings_custom.py # settings for 'custom' tests; different INSTALLED_APPS
settings_contrib.py # settings for 'contrib' tests; different INSTALLED_APPS
的问题是,该命令,它应该只对“的contrib”测试套件运行测试,也发现和“核心”运行测试: ./manage_contrib.py test contrib.tests
如果未安装必要的应用程序,您可以[跳过测试](https://docs.python.org/3/library/unittest.html#skipping-tests-and-expected-failures)。 – knbk