From 950df318b30cde0031f4674d24ed84e93744bad1 Mon Sep 17 00:00:00 2001 From: mgiulini Date: Wed, 11 Dec 2024 16:14:44 +0100 Subject: [PATCH] added test --- tests/test_libio.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_libio.py b/tests/test_libio.py index b917a1242..305ac1dc5 100644 --- a/tests/test_libio.py +++ b/tests/test_libio.py @@ -1,12 +1,14 @@ """Test libio.""" import tempfile from pathlib import Path +import shutil import pytest from haddock.libs.libio import ( clean_suffix, dot_suffix, + extract_files_flat, file_exists, folder_exists, read_from_yaml, @@ -15,6 +17,7 @@ ) from . import emptycfg, haddock3_yaml_cfg_examples +from . import golden_data @pytest.mark.parametrize( @@ -133,3 +136,15 @@ def test_folder_exists_wrong(i): def test_folder_exists_wrong_othererror(): with pytest.raises(TypeError): folder_exists("some_bad_path", exception=TypeError) + + +def test_extract_files_flat(monkeypatch): + """Test extract_files_flat.""" + with tempfile.TemporaryDirectory() as tempdir: + reference_archive = Path(golden_data, "ambig.tbl.tgz") + shutil.copy(reference_archive, tempdir) + monkeypatch.chdir(tempdir) + archive = Path(reference_archive.name) + # extract the archive + extract_files_flat(archive, ".") + assert Path("ambig_1.tbl").exists()