From e162e1281abd02c77e41b82a07561447e1f6cd87 Mon Sep 17 00:00:00 2001 From: Patrick Kidger <33688385+patrick-kidger@users.noreply.github.com> Date: Tue, 12 Jul 2022 10:07:42 +0100 Subject: [PATCH] Made missing beartype result in test skips rather than tests not running --- test/conftest.py | 6 +++++- test/test_import_hook.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/conftest.py b/test/conftest.py index b3264ea..c69a0e3 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -27,7 +27,11 @@ import typeguard try: import beartype except ImportError: - typecheck_params = [typeguard.typechecked] + + def skip(*args, **kwargs): + pytest.skip("Beartype not installed") + + typecheck_params = [typeguard.typechecked, skip] else: typecheck_params = [typeguard.typechecked, beartype.beartype] diff --git a/test/test_import_hook.py b/test/test_import_hook.py index ddde0e4..9077082 100644 --- a/test/test_import_hook.py +++ b/test/test_import_hook.py @@ -35,7 +35,7 @@ def test_import_hook_beartype(): try: import beartype # noqa: F401 except ImportError: - pass + pytest.skip("Beartype not installed") else: hook = install_import_hook( "test.import_hook_tester_beartype", ("beartype", "beartype")