diff --git a/tests/test_query_remote.py b/tests/test_query_remote.py index 2557243d27..27e90e2e42 100644 --- a/tests/test_query_remote.py +++ b/tests/test_query_remote.py @@ -38,13 +38,16 @@ try: from lsst.daf.butler.tests.server import create_test_server -except ImportError: + + reason_text = "" +except ImportError as e: create_test_server = None + reason_text = str(e) TESTDIR = os.path.abspath(os.path.dirname(__file__)) -@unittest.skipIf(create_test_server is None, "Server dependencies not installed.") +@unittest.skipIf(create_test_server is None, f"Server dependencies not installed: {reason_text}") class RemoteButlerQueryTests(ButlerQueryTests, unittest.TestCase): """Test query system using client/server butler.""" diff --git a/tests/test_remote_butler.py b/tests/test_remote_butler.py index 41b1a119ff..b9df899567 100644 --- a/tests/test_remote_butler.py +++ b/tests/test_remote_butler.py @@ -42,20 +42,28 @@ try: import httpx from lsst.daf.butler.remote_butler import ButlerServerError, RemoteButler -except ImportError: + + remote_butler_import_fail_message = "" +except ImportError as e: # httpx is not available in rubin-env yet, so skip these tests if it's not # available RemoteButler = None + remote_butler_import_fail_message = str(e) try: from lsst.daf.butler.tests.server import create_test_server -except ImportError: + + server_import_fail_message = "" +except ImportError as e: create_test_server = None + server_import_fail_message = str(e) TESTDIR = os.path.abspath(os.path.dirname(__file__)) -@unittest.skipIf(RemoteButler is None, "httpx is not installed") +@unittest.skipIf( + RemoteButler is None, f"Remote butler can not be imported: {remote_butler_import_fail_message}" +) class RemoteButlerConfigTests(unittest.TestCase): """Test construction of RemoteButler via Butler()""" @@ -64,7 +72,9 @@ def test_bad_config(self): Butler({"cls": "lsst.daf.butler.remote_butler.RemoteButler", "remote_butler": {"url": "!"}}) -@unittest.skipIf(create_test_server is None, "Server dependencies not installed") +@unittest.skipIf( + create_test_server is None, f"Server dependencies not installed: {server_import_fail_message}" +) class RemoteButlerErrorHandlingTests(unittest.TestCase): """Test RemoteButler error handling.""" @@ -200,7 +210,9 @@ def test_query_projection_drop_postprocessing(self): pass -@unittest.skipIf(create_test_server is None, "Server dependencies not installed.") +@unittest.skipIf( + create_test_server is None, f"Server dependencies not installed: {server_import_fail_message}" +) class RemoteButlerSqliteRegistryTests(RemoteButlerRegistryTests, unittest.TestCase): """Tests for RemoteButler's registry shim, with a SQLite DB backing the server. @@ -209,7 +221,9 @@ class RemoteButlerSqliteRegistryTests(RemoteButlerRegistryTests, unittest.TestCa postgres = None -@unittest.skipIf(create_test_server is None, "Server dependencies not installed.") +@unittest.skipIf( + create_test_server is None, f"Server dependencies not installed: {server_import_fail_message}" +) class RemoteButlerPostgresRegistryTests(RemoteButlerRegistryTests, unittest.TestCase): """Tests for RemoteButler's registry shim, with a Postgres DB backing the server. diff --git a/tests/test_server.py b/tests/test_server.py index c3fb6c31a3..2c6c846608 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -41,8 +41,11 @@ from lsst.daf.butler.remote_butler.server import create_app from lsst.daf.butler.remote_butler.server._dependencies import butler_factory_dependency from lsst.daf.butler.tests.server import TEST_REPOSITORY_NAME, UnhandledServerError, create_test_server -except ImportError: + + reason_text = "" +except ImportError as e: create_test_server = None + reason_text = str(e) from unittest.mock import NonCallableMock, patch @@ -66,7 +69,7 @@ TESTDIR = os.path.abspath(os.path.dirname(__file__)) -@unittest.skipIf(create_test_server is None, "Server dependencies not installed.") +@unittest.skipIf(create_test_server is None, f"Server dependencies not installed: {reason_text}") class ButlerClientServerTestCase(unittest.TestCase): """Test for Butler client/server."""