从nosetests运行中排除特定目录。
项目描述
概述
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_dirs/build和test_dirs/test_not_me目录,从而不在nosetests的测试搜索中使用。
使用基于文件的排除列表
可以使用--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
使用环境变量
可以通过环境变量 NOSE_EXCLUDE_DIRS 和 NOSE_EXCLUDE_TESTS 分别设置 --exclude-dir= 和 --exclude-test=。可以通过分号 ; 分隔多个排除路径。当环境变量 NOSE_EXCLUDE_DIRS_FILE 设置为一个基于文件的排除列表路径时,它将像通过 --exclude-dir-file= 传递一样工作。
Nose 配置文件
nose-exclude 选项也可以通过 .noserc 或 nose.cfg 文件传递给 nosetests。如果需要排除多个目录,可以使用相同的配置键通过换行符分隔它们的值。
[nosetests] exclude-dir=test_dirs/exclude_dirs test_dirs/more_excludes
错误
请将所有错误(和补丁)报告给 https://github.com/kgrandis/nose-exclude/
注意:之前的 bitbucket 仓库不再积极维护。
项目详情
nose-exclude-0.5.0.tar.gz 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | f78fa8b41eeb815f0486414f710f1eea0949e346cfb11d59ba6295ed69e84304 |
|
MD5 | 072f72e782f28a9c42356976f8ec22d9 |
|
BLAKE2b-256 | 63cf90c4be56bf11b7bc8801086d9445baf731aa36b8e8fc5791731e8e604dcd |