0

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

  • If you say _"doesn't work"_: What does it mean - do you get errors, or just a result that differs from your expectation? Could you add an uri-example for which it doesn't work? – Timus May 08 '22 at 01:23
  • [A URL is a **type** of URI](https://stackoverflow.com/a/28865728/1145388). It doesn't make sense to say "get not only URL, but URI too" because a URL **is** always a URI. Do you mean that you want to get both relative and absolute URLs? – Stephen Ostermiller May 08 '22 at 07:41

0 Answers0