问题标签 [nose2]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
2846 浏览

python - 尝试运行命令“sudo tox”时出现 Tox 调用错误

在 virtualenv [3.4] 中工作时,当我遇到错误时,我试图运行 tox 来运行测试:

我已经尝试使用 pip install nose2 安装nose2,但问题仍然存在。

0 投票
2 回答
772 浏览

python - nose2:从导入的模块运行测试

我生成并导入了一个模块,其中包含我想运行的测试nose2。以下是创建和导入模块的代码:


编辑:我通过使用临时文件解决了这个问题。它对我有用,但我仍然对如何通过动态生成模块感到好奇。这是使用临时文件执行此操作的代码:

0 投票
1 回答
242 浏览

python - 如何在nose2中检查测试运行结果?

我可以检查在unittest测试运行期间是否有失败的测试,如下所示:

如何做同样的事情nose2

0 投票
1 回答
2568 浏览

python - 如何使用nose2从给定包中获取覆盖率报告

我想使用带有覆盖率插件的nose2来获得Python包的覆盖率,但我很难将它配置为仅覆盖我正在处理的包。该包被调用vimhdl,我的覆盖部分unittest.cfg如下所示:

使用nose2,结果不包括包中的所有文件(可能是因为Coverage.py warning: Module vimhdl was previously imported, but not measured.消息,但我不知道如何修复它)。

此外,当打开给定文件的 HTML 报告时,诸如 import logging和模块的文档字符串之类的语句被标记为未涵盖。

另一方面,使用nosetests,结果按预期包括所有文件。

如何配置nose2覆盖插件以仅覆盖给定模块?

如果有帮助,源代码位于https://github.com/suoto/vim-hdl/tree/unstable的 github 上。

0 投票
1 回答
169 浏览

python - 使用这种 DSL 的鼻子2 找不到测试

这可能真的很愚蠢,但我无法让它工作......我想在 Linux 中将suchDLSnose2与 python 2.7 一起使用。我正在尝试文档http://nose2.readthedocs.org/en/latest/such_dsl.html中示例的开头(请参见下面的代码),但无论我如何启动它,它都不会运行测试从命令行。

我的文件名为 test_something.py,它是目录中唯一的文件。>> nose2我试过用and从命令行运行>> nose2 --plugin nose2.plugins.layers,但我总是得到Ran 0 tests in 0.000s. 随着>> nose2 --plugin layers我得到ImportError: No module named layers.

我应该如何从命令行运行这个测试?谢谢!

下面的代码:

0 投票
3 回答
5992 浏览

python - How to conditionally skip a test in python

I would like to skip some test functions when a condition is met, for example:

Here I expect the test method to be reported as skipped if condition evaluated to true. I was able to do this with some effort with nose, but I would like to see if it is possible in nose2.

Related question describes a method for skipping all tests in nose2.

0 投票
1 回答
2209 浏览

python - 如何在 python unittest 中指定测试特定的设置和拆卸

我想用两个不同的测试在同一个类中创建具有两个不同设置和 tearDown 方法的单元测试测试。

每个测试都将在 python unittest 框架中使用其特定的 setUp 和 tearDown 方法。

谁能帮助我。

0 投票
1 回答
417 浏览

python - nose2.main() 详细输出

我正在为我的程序编写一个单独的nose2 tests.py,因为我希望它可以相当无缝地在Windows和Linux上运行,所以我决定放弃使用普通命令行nose2,而是将它导入文件并从那里运行它.

这工作正常,没有问题。但我想要详细的输出,但我不知道如何让它做到这一点。我试过了:

任何人都知道如何让nose2的导入版本以详细模式运行?

0 投票
1 回答
668 浏览

python - 具有相对熊猫文件路径的 Python 鼻子测试

我正在尝试为一段代码编写单元测试,其中包括使用 pandas 从相对路径读取 CSV 文件。目录结构为:

main.py中,我有:

test_main.py,我有

如果我运行,一切正常main.py,但是当我要求 Anaconda“运行项目测试”时,我收到一个 IOError 抱怨 'dat/file.csv' 不存在。这与它是相对路径这一事实有关,因为当我将其更改为 时/home/user/.../thing1/dat/file.csv,它可以工作。有没有一种方法可以在保持相对路径的同时使单元测试工作?

0 投票
0 回答
350 浏览

python - 强制 nose2 使用 Python 2.7 而不是 Python 3.5

Force Nosetests to Use Python 2.7 而不是 3.4类似,我在 Python 2 中编写了一些单元测试,我想在 Python 2 中运行。但是,默认情况下,我的安装nose2似乎尝试运行 Python 3。

例如,如果我尝试运行,unittest_controller.py我会得到以结尾的输出

而如果我使用nose2同一目录中的命令,我会得到

因为StringIO不再是 Python 3 中的模块。如何使用 Python 2 运行测试?