从nosetests运行中排除特定目录。
nose-exclude的Python项目详细描述
概述
nose exclude是一个Nose插件,它允许您轻松地指定 要从测试中排除的目录。
排除目录
--exclude-dir=选项在安装 插件。此选项可以多次用于排除多个目录 从测试开始。提供的目录路径可以是绝对路径或相对路径。
示例:
$ nosetests --exclude-dir=test_dirs/build \ --exclude-dir=test_dirs/test_not_me test_dirs .... ---------------------------------------------------------------------- Ran 4 tests in 0.006s OK
此示例将排除目录test\u dirs/build和 从鼻测试的测试搜索中,测试方向/测试不是我。
使用基于文件的排除列表
--exclude-dir-file=选项可用于传入预定义的 文件中包含的目录列表。nose-exclude需要每个 目录被排除在自己的行上。
示例:
$ nosetests --exclude-dir-file=test_dirs/exclude_dirs.txt \ test_dirs .... ---------------------------------------------------------------------- Ran 4 tests in 0.006s OK
其中exclude_dirs.txt可能看起来像:
test_dirs/build # Start a line with a '#' to include # Comments test_dirs/test_not_me
不包括特定的试验方法和等级
现在可以通过指定完全限定的测试路径来排除测试。 可以使用--exclude-test或--exclude-test-file排除测试。
排除测试方法:
--exclude-test=module1.module2.TestClass.test_method
排除测试类:
--exclude-test=module1.module2.TestClass
排除测试功能:
--exclude-test=module1.module2.test_function
使用环境变量
--exclude-dir=和--exclude-test=可以由环境设置 变量分别为NOSE_EXCLUDE_DIRS和NOSE_EXCLUDE_TESTS。 可以使用;分隔多个排除路径。这个 环境变量NOSE_EXCLUDE_DIRS_FILE设置为 基于文件的排除列表函数,就好像它是随 --exclude-dir-file=。
鼻配置文件
nose-exclude选项也可以使用.noserc或nose.cfg文件传递给nosetests。如果要排除多个目录 使用相同的配置键用新行分隔它们的值:
[nosetests] exclude-dir=test_dirs/exclude_dirs test_dirs/more_excludes