From 10e3478b12acea78a7e57035797aa863ca7bc82e Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Wed, 10 Oct 2018 17:17:02 +0800 Subject: [PATCH] fix test_keyfile keyfile is not part of cache keys so the expectations are wrong. We don't make it part of cache keys because we don't expect keyfile to affect the version as long as we can get it. --- tests/conftest.py | 6 +++++- tests/test_keyfile.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 6398d7d..e9fe7b5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,6 +5,7 @@ import io import structlog from nvchecker.get_version import get_version as _get_version +from nvchecker.get_version import _cache from nvchecker.core import Source class TestSource(Source): @@ -22,7 +23,10 @@ class TestSource(Source): self._future.set_exception(exc) @pytest.fixture(scope="module") -async def run_source(): +async def run_source(*, clear_cache=False): + if clear_cache: + _cache.clear() + async def __call__(conf): future = asyncio.Future() file = io.StringIO(conf) diff --git a/tests/test_keyfile.py b/tests/test_keyfile.py index 09346f4..2eec251 100644 --- a/tests/test_keyfile.py +++ b/tests/test_keyfile.py @@ -46,7 +46,7 @@ keyfile = {name} '''.format(name=f.name) try: - version = await run_source(test_conf) + version = await run_source(test_conf, clear_cache=True) assert version is None # out of allowance return except HTTPError as e: