From 245118e6fd523c67e4dd4bfd9e6d6e57abe2d08e Mon Sep 17 00:00:00 2001 From: Hagen Wierstorf Date: Fri, 26 Jul 2024 09:12:28 +0200 Subject: [PATCH] TST: fix tests for audformat>=1.3.0 (#445) * TST: fix tests for audformat>=1.3.0 * Use storage format variable in asserts --- tests/conftest.py | 7 +++++++ tests/test_load.py | 5 ----- tests/test_load_on_demand.py | 8 ++++---- tests/test_publish.py | 6 +++--- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 28e6faf8..fc7052f9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -241,3 +241,10 @@ def non_existing_repository(): def hide_default_repositories(): r"""Hide default audb repositories during testing.""" audb.config.REPOSITORIES = [] + + +# ===== STORAGE FORMAT ===== +@pytest.fixture(scope="module", autouse=False) +def storage_format(): + """Storage format of tables.""" + yield "csv" diff --git a/tests/test_load.py b/tests/test_load.py index ece6f9db..dc1a7099 100644 --- a/tests/test_load.py +++ b/tests/test_load.py @@ -33,11 +33,6 @@ def assert_database_tmp_folder_is_deleted(): assert len([d for d in dirs if d.endswith("~")]) == 0 -@pytest.fixture(scope="module", autouse=False) -def storage_format(): - yield "csv" - - @pytest.fixture( scope="module", autouse=True, diff --git a/tests/test_load_on_demand.py b/tests/test_load_on_demand.py index 830bc777..17fb4513 100644 --- a/tests/test_load_on_demand.py +++ b/tests/test_load_on_demand.py @@ -17,7 +17,7 @@ scope="module", autouse=True, ) -def dbs(tmpdir_factory, persistent_repository): +def dbs(tmpdir_factory, persistent_repository, storage_format): # Collect single database paths # and return them in the end paths = {} @@ -64,7 +64,7 @@ def dbs(tmpdir_factory, persistent_repository): audeer.touch(db_root, "file.txt") audeer.touch(db_root, "folder/file1.txt") audeer.touch(db_root, "folder/file2.txt") - db.save(db_root) + db.save(db_root, storage_format=storage_format) audformat.testing.create_audio_files(db) audb.publish( @@ -77,7 +77,7 @@ def dbs(tmpdir_factory, persistent_repository): return paths -def test_load_only_metadata(dbs): +def test_load_only_metadata(dbs, storage_format): db_original = audformat.Database.load(dbs[DB_VERSION]) db = audb.load( @@ -103,7 +103,7 @@ def test_load_only_metadata(dbs): # Delete table1 # to force downloading from backend again - os.remove(os.path.join(db.meta["audb"]["root"], "db.table1.csv")) + os.remove(os.path.join(db.meta["audb"]["root"], f"db.table1.{storage_format}")) os.remove(os.path.join(db.meta["audb"]["root"], "db.table1.pkl")) db = audb.load( DB_NAME, diff --git a/tests/test_publish.py b/tests/test_publish.py index 104dd953..daf900f4 100644 --- a/tests/test_publish.py +++ b/tests/test_publish.py @@ -1064,7 +1064,7 @@ def test_publish_error_version(tmpdir, repository): audb.publish(db_path, "2.0.0", repository, previous_version="1.0.0?") -def test_publish_text_media_files(tmpdir, dbs, repository): +def test_publish_text_media_files(tmpdir, dbs, repository, storage_format): r"""Test publishing databases containing text files as media files.""" # Create a database, containing text media file build_dir = audeer.path(tmpdir, "./build") @@ -1079,13 +1079,13 @@ def test_publish_text_media_files(tmpdir, dbs, repository): db["files"] = audformat.Table(index) db["files"]["speaker"] = audformat.Column(scheme_id="speaker") db["files"]["speaker"].set(["adam"]) - db.save(build_dir) + db.save(build_dir, storage_format=storage_format) # Publish database, containing text media file version = "1.0.0" deps = audb.publish(build_dir, version, repository) - assert deps.tables == ["db.files.csv"] + assert deps.tables == [f"db.files.{storage_format}"] file = "data/file1.txt" assert deps.media == [file] assert deps.bit_depth(file) == 0