From fd252e391132b6957b309dfcd689ebb3c026c030 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Fri, 17 May 2024 18:14:00 -0700 Subject: [PATCH] fix string checking in raised asserts --- src/numpydantic/interface/interface.py | 2 +- tests/test_interface/test_interface.py | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/numpydantic/interface/interface.py b/src/numpydantic/interface/interface.py index 3dfc596..14e1231 100644 --- a/src/numpydantic/interface/interface.py +++ b/src/numpydantic/interface/interface.py @@ -115,7 +115,7 @@ class Interface(ABC, Generic[T]): Convert an array of :attr:`.return_type` to a JSON-compatible format using base python types """ - if not isinstance(array, np.ndarray): + if not isinstance(array, np.ndarray): # pragma: no cover array = np.array(array) return array.tolist() diff --git a/tests/test_interface/test_interface.py b/tests/test_interface/test_interface.py index 337ec93..0efd38d 100644 --- a/tests/test_interface/test_interface.py +++ b/tests/test_interface/test_interface.py @@ -1,3 +1,5 @@ +import pdb + import pytest import numpy as np @@ -47,21 +49,21 @@ def test_interface_match_error(interfaces): """ with pytest.raises(ValueError) as e: Interface.match([1, 2, 3]) - assert "Interface1" in e - assert "Interface2" in e + assert "Interface1" in str(e.value) + assert "Interface2" in str(e.value) with pytest.raises(ValueError) as e: - Interface.match([[1, 2, 3], ["hey"]]) - assert "No matching interfaces" in e + Interface.match(([1, 2, 3], ["hey"])) + assert "No matching interfaces" in str(e.value) with pytest.raises(ValueError) as e: Interface.match_output((1, 2, 3)) - assert "Interface1" in e - assert "Interface2" in e + assert "Interface1" in str(e.value) + assert "Interface2" in str(e.value) with pytest.raises(ValueError) as e: Interface.match_output("hey") - assert "No matching interfaces" in e + assert "No matching interfaces" in str(e.value) def test_interface_enabled(interfaces):