gpt4 book ai didi

python - 使用 nose 分别运行单元和集成测试(驻留在不同的目录中)

转载 作者:行者123 更新时间:2023-11-28 20:09:05 25 4
gpt4 key购买 nike

我想知道这个问题已经有一段时间了,但我无法弄清楚如何将选项传递给 nosetests 以运行驻留在不同子目录中的不同测试。包目录结构示例:

my_package/
|-- my_module1/
|-- tests/
|-- unit/
| ... a bunch of unit tests
|-- integration/
|... a bunch of integration tests
|-- my_module2/
|-- tests/
|-- unit/
| ... a bunch of unit tests
|-- integration/
|... a bunch of integration tests

如果我只想在所有模块中执行单元测试(tests/unit/ 子目录中的所有测试),我该如何使用 nosetests 库执行此操作?

最佳答案

我认为 --where--match nosetests arguments 可以帮助你:

-w WHERE, --where=WHERE Look for tests in this directory. May be specified multiple times. The first directory passed will be used as the working directory, in place of the current working directory, which is the default. Others will be added to the list of tests to execute. [NOSE_WHERE]

-m REGEX, --match=REGEX, --testmatch=REGEX Files, directories, function names, and class names that match this regular expression are considered tests. Default: (?:^|[\b_./-])[Tt]est [NOSE_TESTMATCH]

另请参阅 Anyone know how nosetest's -m, -i and -e work?

但是,实际上,我更喜欢在根级别拥有测试目录:How to organize and run unittests and functional tests separately using nosetests

关于python - 使用 nose 分别运行单元和集成测试(驻留在不同的目录中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15543100/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com