fix string checking in raised asserts

This commit is contained in:
sneakers-the-rat 2024-05-17 18:14:00 -07:00
parent a1a440e6ad
commit fd252e3911
Signed by untrusted user who does not match committer: jonny
GPG key ID: 6DCB96EF1E4D232D
2 changed files with 10 additions and 8 deletions

View file

@ -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()

View file

@ -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):