From 1634d3fe8ff80b1490e685fac5643404cab21825 Mon Sep 17 00:00:00 2001 From: kba Date: Tue, 16 Jul 2024 16:51:55 +0200 Subject: [PATCH] test_ocrd_mets: tests in docker have OCRD_METS_CACHING=1 always, unset --- tests/model/test_ocrd_mets.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/model/test_ocrd_mets.py b/tests/model/test_ocrd_mets.py index 3bf342b8ef..5062fe2270 100644 --- a/tests/model/test_ocrd_mets.py +++ b/tests/model/test_ocrd_mets.py @@ -61,10 +61,11 @@ def test_unique_identifier_from_nothing(): def test_str(): - mets = OcrdMets(content='', cache_flag=False) - assert str(mets) == 'OcrdMets[cached=False,fileGrps=[],files=[]]' - mets_cached = OcrdMets(content='', cache_flag=True) - assert str(mets_cached) == 'OcrdMets[cached=True,fileGrps=[],files=[]]' + with temp_env_var('OCRD_METS_CACHING', None): + mets = OcrdMets(content='', cache_flag=False) + assert str(mets) == 'OcrdMets[cached=False,fileGrps=[],files=[]]' + mets_cached = OcrdMets(content='', cache_flag=True) + assert str(mets_cached) == 'OcrdMets[cached=True,fileGrps=[],files=[]]' def test_file_groups(sbb_sample_01): @@ -383,12 +384,15 @@ def test_invalid_filegrp(): @contextmanager def temp_env_var(k, v): v_before = environ.get(k, None) - environ[k] = v + if v == None: + environ.pop(k, None) + else: + environ[k] = v yield if v_before is not None: environ[k] = v_before else: - del environ[k] + environ.pop(k, None) def test_envvar(): assert OcrdMets(filename=assets.url_of('SBB0000F29300010000/data/mets.xml'), cache_flag=True)._cache_flag