Fixes build [1]
[1] https://jenkins.softwareheritage.org/job/DVAU/job/tests/807/console
Differential D4134
tests: Fix loader git instantiation ardumont on Oct 2 2020, 6:05 PM. Authored by
Details
Fixes build [1] [1] https://jenkins.softwareheritage.org/job/DVAU/job/tests/807/console tox
Diff Detail
Event TimelineComment Actions Build is green Patch application report for D4134 (id=14576)Rebasing onto b0c50dd168... Current branch diff-target is up to date. Changes applied before testcommit 7af35ae919caa67c62c4e48571f18fa06e504631 Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org> Date: Fri Oct 2 18:05:44 2020 +0200 tests: Fix loader git instantiation Fixes build [1] [1] https://jenkins.softwareheritage.org/job/DVAU/job/tests/807/console See https://jenkins.softwareheritage.org/job/DVAU/job/tests-on-diff/18/ for more details. Comment Actions Looks good ! I think we could simplify the git loader creation by making git_loader a pytest fixture. This could be added in a second commit or I can open a diff with my local experiments (see diff extract below) diff --git a/swh/vault/tests/test_cookers.py b/swh/vault/tests/test_cookers.py index 42b9243..a86027f 100644 --- a/swh/vault/tests/test_cookers.py +++ b/swh/vault/tests/test_cookers.py @@ -129,20 +129,25 @@ def swh_loader_config(swh_loader_config): return swh_loader_config +@pytest.fixture def git_loader( - storage, - repo_path, - visit_date=datetime.datetime.now(datetime.timezone.utc), - config=None, + swh_storage, swh_loader_config, ): """Instantiate a Git Loader using the storage instance as storage. """ - loader = GitLoaderFromDisk( - "fake_origin", directory=repo_path, visit_date=visit_date, config=config - ) - loader.storage = storage - return loader + + def _create_loader(directory): + loader = GitLoaderFromDisk( + "fake_origin", + directory=directory, + visit_date=datetime.datetime.now(datetime.timezone.utc), + config=swh_loader_config, + ) + loader.storage = swh_storage + return loader + + return _create_loader @contextlib.contextmanager @@ -196,7 +201,7 @@ TEST_EXECUTABLE = b"\x42\x40\x00\x00\x05" class TestDirectoryCooker: - def test_directory_simple(self, swh_storage, swh_loader_config): + def test_directory_simple(self, git_loader): repo = TestRepo() with repo as rp: (rp / "file").write_text(TEST_CONTENT) @@ -206,13 +211,13 @@ class TestDirectoryCooker: (rp / "dir1/dir2").mkdir(parents=True) (rp / "dir1/dir2/file").write_text(TEST_CONTENT) c = repo.commit() - loader = git_loader(swh_storage, str(rp), config=swh_loader_config) + loader = git_loader(str(rp)) loader.load() obj_id_hex = repo.repo[c].tree.decode() obj_id = hashutil.hash_to_bytes(obj_id_hex) - with cook_extract_directory(swh_storage, obj_id) as p: + with cook_extract_directory(loader.storage, obj_id) as p: assert (p / "file").stat().st_mode == 0o100644 assert (p / "file").read_text() == TEST_CONTENT assert (p / "executable").stat().st_mode == 0o100755 Comment Actions
thanks, it crossed my mind... Thanks for the suggestion \m/ |