You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a fixture that creates a test database, and that is session-scoped. For one of the tests, I want to call that fixture again with an argument set to false. I can extract the contents of the fixture into another method (so that the fixture becomes just a wrapper around that method), but I am wondering if there is any way to do this with the existing fixture. In short, what I want to do is something like:
@pytest.fixture(scope='session')
def db_init(upgrade=False):
if upgrade:
upgrade()
else:
db.create_all()
class TestInitApp:
@pytest.mark.parametrize("db_init", [True], indirect=["db_init"])
def test_file_exists(self, app, db_init):
# do the test
But I do not get this to work. What am I doing wrong?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a fixture that creates a test database, and that is session-scoped. For one of the tests, I want to call that fixture again with an argument set to false. I can extract the contents of the fixture into another method (so that the fixture becomes just a wrapper around that method), but I am wondering if there is any way to do this with the existing fixture. In short, what I want to do is something like:
But I do not get this to work. What am I doing wrong?
Beta Was this translation helpful? Give feedback.
All reactions