我是 pytest 框架的新手。我需要在类上创建一个带有参数化夹具的测试用例。我创建了如下测试用例。但它抛出一个错误: TypeError:TestClass.test_case_parameterized() 缺少 1 个必需的位置参数:'文件名' 请有人帮忙解决这个问题
import pytest
import unittest
from moto import mock_aws
@pytest.mark.parametrize("filename", ["testFile1.txt", "testFile2.txt"])
@mock_aws
class TestClass(unittest.TestCase):
def test_case_parameterized(self, filename):
print(f"filename = {filename}")
#further aws api call processing`
如果你想使用pytest框架,你可以更改你的代码如下:
import pytest
from moto import mock_aws
@pytest.mark.parametrize("filename", ["testFile1.txt", "testFile2.txt"])
@mock_aws
class TestClass():
def test_case_parameterized(self, filename):
print(f"filename = {filename}")
# further aws api call processing
# your assertion