I setup my tests via this command line:
python -m pytest —top=10 —user=20 .\test_orm.py
conftest.py
def pytest_addoption(parser):
parser.addoption(
"--top", action='store', default='10', help='write the number of top requests you want to add in database'
)
parser.addoption(
"--user", action='store', default='5', help='write the number of user requests you want to add in database'
)
@pytest.fixture(scope='session')
def top(request):
top = request.config.getoption("--top")
return int(top)
@pytest.fixture(scope='session')
def user(request):
user = request.config.getoption("--user")
return int(user)
test.py
class TestRequestsTop(BaseMySQL):
def parse(self, log_path, top):
data = log_parse.get_requests_top(log_path, top)
for _ in data:
self.builder.create_requests_top(url=_[0], count=_[1])
self.result = len(data)
def test_requests_top(self):
data = self.client.session.query(RequestsTop).all()
assert len(data) == self.result
class TestRequests500(BaseMySQL):
def parse(self, log_path, user):
data = log_parse.get_requests_500(log_path, user)
for _ in data:
self.builder.create_requests_500(ip=_[0], requests_number=_[1])
self.result = len(data)
def test_requests_500(self):
data = self.client.session.query(Requests500).all()
assert len(data) == self.result
i get this error:
ERROR test_orm.py::TestRequestsTop::test_requests_top - TypeError: TestRequestsTop.parse() missing 1 required positional argument: 'top'
ERROR test_orm.py::TestRequests500::test_requests_500 - TypeError: TestRequests500.parse() missing 1 required positional argument: 'user'
Dont understand what should i do