From 07ce8bb585f47a17a2d148b6eb73eef0383c0b61 Mon Sep 17 00:00:00 2001 From: Eduardo Rodrigues Date: Wed, 1 May 2024 00:20:19 +0200 Subject: [PATCH] Improve test coverage a little bit --- src/skhep_testdata/__init__.py | 2 +- src/skhep_testdata/local_files.py | 2 +- src/skhep_testdata/remote_files.py | 2 +- tests/test_local_files.py | 8 +++++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/skhep_testdata/__init__.py b/src/skhep_testdata/__init__.py index 8ce95d0..6b76598 100644 --- a/src/skhep_testdata/__init__.py +++ b/src/skhep_testdata/__init__.py @@ -6,5 +6,5 @@ __all__ = ("data_path", "download_all", "known_files", "__version__") -def __dir__() -> tuple[str, ...]: +def __dir__() -> tuple[str, ...]: # pragma: no cover return __all__ diff --git a/src/skhep_testdata/local_files.py b/src/skhep_testdata/local_files.py index d4d28da..1d50af5 100644 --- a/src/skhep_testdata/local_files.py +++ b/src/skhep_testdata/local_files.py @@ -10,7 +10,7 @@ from . import data, remote_files if sys.version_info < (3, 9): - import importlib_resources as resources + import importlib_resources as resources # pragma: no cover else: from importlib import resources diff --git a/src/skhep_testdata/remote_files.py b/src/skhep_testdata/remote_files.py index c302a4a..b85216c 100644 --- a/src/skhep_testdata/remote_files.py +++ b/src/skhep_testdata/remote_files.py @@ -11,7 +11,7 @@ import yaml if sys.version_info < (3, 9): - import importlib_resources as resources + import importlib_resources as resources # pragma: no cover else: from importlib import resources diff --git a/tests/test_local_files.py b/tests/test_local_files.py index d375dc4..34e8a76 100644 --- a/tests/test_local_files.py +++ b/tests/test_local_files.py @@ -1,8 +1,8 @@ from __future__ import annotations import os - import pytest +import requests import skhep_testdata as skhtd @@ -25,6 +25,12 @@ def test_data_path_missing(): skhtd.data_path("doesnt-exist.root", raise_missing=True) +def test_data_path_cached(): + skhtd.known_files.add("dummy-cached.root") + with pytest.raises(requests.exceptions.HTTPError): + skhtd.data_path("dummy-cached.root", raise_missing=False, cache_dir="tmp") + + def test_delegate_to_remote(monkeypatch, tmpdir): def dummy_remote_file(filename, data_dir=None, raise_missing=False): if not data_dir: