Skip to content

Commit

Permalink
TST: fix tests for audformat>=1.3.0 (#445)
Browse files Browse the repository at this point in the history
* TST: fix tests for audformat>=1.3.0

* Use storage format variable in asserts
  • Loading branch information
hagenw authored Jul 26, 2024
1 parent eaa9207 commit 245118e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 0 additions & 5 deletions tests/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions tests/test_load_on_demand.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions tests/test_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down

0 comments on commit 245118e

Please sign in to comment.