【发布时间】:2019-12-21 23:35:24
【问题描述】:
我从官方示例中获取代码:
import pytest
@pytest.mark.parametrize("test_input,expected", [
("3+5", 8),
("2+4", 6),
("6*9", 42),
])
def test_eval(test_input, expected):
assert eval(test_input) == expected
但它给出了错误:
.E
======================================================================
ERROR: test_config.test_eval
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\nose\case.py", line 197, in runTest
self.test(*self.arg)
TypeError: test_eval() missing 2 required positional arguments: 'test_input' and 'expected'
----------------------------------------------------------------------
Ran 2 tests in 0.000s
FAILED (errors=1)
Error
Traceback (most recent call last):
File "C:\Anaconda3\lib\unittest\case.py", line 59, in testPartExecutor
yield
File "C:\Anaconda3\lib\unittest\case.py", line 601, in run
testMethod()
File "C:\Anaconda3\lib\site-packages\nose\case.py", line 197, in runTest
self.test(*self.arg)
TypeError: test_eval() missing 2 required positional arguments: 'test_input' and 'expected'
Process finished with exit code 1
pytest version 5.0.1
这里有什么问题?
【问题讨论】:
-
将所有参数化的东西放在同一行时,它有没有可能起作用?
-
无法重现。使用 pytest 5.0.1 可以正常工作
标签: python python-3.x typeerror pytest