From ba538fee721f49dd24733c0b3bac98d2cb507eac Mon Sep 17 00:00:00 2001 From: Dylan Reinhardt Date: Mon, 18 Sep 2023 15:18:04 -0700 Subject: [PATCH] Provide example test fixture --- src/biocommons/example/tests/conftest.py | 10 ++++++++++ src/biocommons/example/tests/marvin_subdir_test.py | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 src/biocommons/example/tests/conftest.py diff --git a/src/biocommons/example/tests/conftest.py b/src/biocommons/example/tests/conftest.py new file mode 100644 index 0000000..31f4c0f --- /dev/null +++ b/src/biocommons/example/tests/conftest.py @@ -0,0 +1,10 @@ +import importlib + +import pytest +import yaml + + +@pytest.fixture +def all_quotes(): + quotes_stream = importlib.resources.files("example").joinpath("quotes.yaml").read_text() + return yaml.load(quotes_stream, Loader=yaml.SafeLoader)["quotes"] diff --git a/src/biocommons/example/tests/marvin_subdir_test.py b/src/biocommons/example/tests/marvin_subdir_test.py index 79c431a..0eeecdd 100644 --- a/src/biocommons/example/tests/marvin_subdir_test.py +++ b/src/biocommons/example/tests/marvin_subdir_test.py @@ -3,6 +3,7 @@ from ..marvin import get_quote -def test_get_quote(): +def test_get_quote(all_quotes): """test get_quote""" - assert get_quote() is not None + # NB: all_quotes argument is a test fixture; see ./conftest.py + assert get_quote() in all_quotes