From 6d590103ee1b89743e9168184b1b03133bb7d7b6 Mon Sep 17 00:00:00 2001 From: missytake Date: Sat, 14 Oct 2023 15:05:59 +0200 Subject: [PATCH] tests: move database initialization to fixture --- doveauth/src/doveauth/test_doveauth.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/doveauth/src/doveauth/test_doveauth.py b/doveauth/src/doveauth/test_doveauth.py index e42e0bc..907c251 100644 --- a/doveauth/src/doveauth/test_doveauth.py +++ b/doveauth/src/doveauth/test_doveauth.py @@ -4,15 +4,18 @@ import pytest from doveauth.doveauth import get_user_data, verify_user, Database -def test_basic(tmpdir): - db = Database(tmpdir / "passdb.sqlite") +@pytest.fixture() +def db(tmpdir): + return Database(tmpdir / "passdb.sqlite") + + +def test_basic(db): verify_user(db, "link2xt@c1.testrun.org", "asdf") data = get_user_data(db, "link2xt@c1.testrun.org") assert data -def test_verify_or_create(tmpdir): - db = Database(tmpdir / "passdb.sqlite") +def test_verify_or_create(db): res = verify_user(db, "newuser1@something.org", "kajdlkajsldk12l3kj1983") assert res["status"] == "ok" res = verify_user(db, "newuser1@something.org", "kajdlqweqwe")