diff options
author | Daniel Schadt <kingdread@gmx.de> | 2023-11-13 18:35:03 +0100 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2023-11-13 18:35:03 +0100 |
commit | eac4f7a7f7fec9585a7c080400c4ae8fa9b67578 (patch) | |
tree | 21932471bf6fbe7ba424cae1223bf6468d8176d5 /tests/conftest.py | |
parent | 9a31dd6651d8a47943e63db212bce7245a152450 (diff) | |
download | fietsboek-eac4f7a7f7fec9585a7c080400c4ae8fa9b67578.tar.gz fietsboek-eac4f7a7f7fec9585a7c080400c4ae8fa9b67578.tar.bz2 fietsboek-eac4f7a7f7fec9585a7c080400c4ae8fa9b67578.zip |
make test app fixture module-scoped
Previously, we had it session-scoped, which meant that the app was
created once for all tests. This doesn't allow us to play with different
settings however, such as disabling account registration or image
uploads and testing that.
Now, the fixtures are module scoped, which means that we still save on
prepare/teardown time a bit, but we're also a bit more flexible. By
making new test modules, we can test different settings there.
Diffstat (limited to 'tests/conftest.py')
-rw-r--r-- | tests/conftest.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index a4366ab..94f795a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -28,11 +28,14 @@ def ini_file(request): # potentially grab this path from a pytest option return os.path.abspath(request.config.option.ini or 'testing.ini') -@pytest.fixture(scope='session') +# Even though the ini file is scoped to session, we scope the actual settings +# to module only. This way, we can test different configurations in different +# modules. +@pytest.fixture(scope='module') def app_settings(ini_file): return get_appsettings(ini_file) -@pytest.fixture(scope='session') +@pytest.fixture(scope='module') def dbengine(app_settings, ini_file): engine = models.get_engine(app_settings) @@ -73,7 +76,7 @@ def _cleanup_data(app_settings): if (data_dir / "tracks").is_dir(): shutil.rmtree(data_dir / "tracks") -@pytest.fixture(scope='session') +@pytest.fixture(scope='module') def app(app_settings, dbengine, tmp_path_factory): app_settings["fietsboek.data_dir"] = str(tmp_path_factory.mktemp("data")) logging.getLogger().setLevel(logging.DEBUG) |