我目前正在关注这个py.test示例,当我不使用类时,它会工作,但是当我将测试用例引入类时,我失败了.
我设法编写的最小案例如下:
import unittest
import pytest
class FixtureTestCase(unittest.TestCase):
@pytest.mark.parametrize("test_input,expected", [
("3+5", 8),
("2+4", 6),
("6*9", 42),
])
def test_1(self, a, b):
self.assertEqual(a, b)
Run Code Online (Sandbox Code Playgroud)
不幸的是,当我执行
py.test test_suite.py
Run Code Online (Sandbox Code Playgroud)
我收到错误消息:
TypeError: test_1() takes exactly 3 arguments (1 given)
Run Code Online (Sandbox Code Playgroud)
如何生成一系列test_1测试?