I’ve read the pytest fixture parametrization documentation but struggle on the most simple task now.
How can I have f
and f1
returned as_file
?
import pytest
@pytest.fixture
def as_file(arg):
with open(arg) as f:
return f
@pytest.fixture
def f(as_file):
return as_file("f.txt")
@pytest.fixture
def f1(as_file):
return as_file("f1.txt")
def test(f,f2):
assert f.name == "f.txt"
assert f1.name == "f1.txt"
1