鼻子参数化测试函数的打印名

2024-09-28 21:54:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我有扩展unittest.TestCase的测试类,并使用nose_parameterized进行参数化。我使用nosetests -v来运行测试。我有鼻子测试版本1.3.7。在

我想让测试运行人员打印每个测试的名称。相反,它只打印传入测试的参数。在

<我的实际输出示例:

[with sentence='Put it on the top shelf of the bookshelf'] ... ok
[with **None={'world': [<WorldObject table>, ...'basic', 'language': 'Pick cup'}] ... ERROR
[with **None={'name': 'first action', 'langua...'' ... ERROR
[with **None={'name': 'two pointing choices',...'' ... ERROR

基于nose_parameterizeddocumentation示例,我认为输出应该包含测试方法及其类的名称,大致如下所示。在

^{pr2}$

但事实并非如此

documentation进一步说明:

If the first parameter is a string, that string will be added to the end of the method name.

因此,根据我作为每个测试的第一个参数传入的字符串,输出应该如下所示:

language_analyzer_test_Pick_cup (md.LangaugeAnalyzerTest) ... ok
language_test_basic (md.ReferenceResolverTest) ... ERROR
reference_resolver_test_first_action (md.ReferenceResolverTest) ... ERROR
reference_resolver_test_two_pointing_choices (md.ReferenceResolverTest) ... ERROR

但是,唉。在

根据实际的输出,很难分辨出哪个测试方法正在运行,甚至很难判断它来自哪个测试类。在

如何让nose打印每个测试用例的测试名称?


Tags: ofthenametest名称none参数with