0

I am wanting to do something along the lines of:

  • I have a client fixture that takes in two parameters, url & is_caching
  • the url parameter is sent in using pytest.mark.parameterize
  • however the is_caching is determined by the function

How can I pass in the is_caching parameter in to the fixture, given that I also want the function name to have "names" as the suffix during collection

test_logging_disabled[n1] test_logging_disabled[n2]

import pytest

@pytest.fixture(scope = "session", autouse = True)
def client(url, is_caching = True):
    kwargs = {'is_caching': is_caching}
    client = Client(url, **kwargs)
    yield client
    client.close()

@pytest.mark.parameterize("url", ["n1","n2"], ids = ["n1","n2"], indirect = True):
def test_caching_disabled(client): 
    #test

rustyocean
  • 237
  • 5
  • 14

0 Answers0