跳转到主要内容

从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_DIRSNOSE_EXCLUDE_TESTS 分别设置 --exclude-dir=--exclude-test=。可以通过分号 ; 分隔多个排除路径。当环境变量 NOSE_EXCLUDE_DIRS_FILE 设置为一个基于文件的排除列表路径时,它将像通过 --exclude-dir-file= 传递一样工作。

Nose 配置文件

nose-exclude 选项也可以通过 .nosercnose.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 (7.4 kB 查看哈希)

上传时间

支持者: