Skip to content

Commit 2224ea5

Browse files
committed
Handle matrix warnings in test_interconnect_unused_{input,output}
Ignore warnings with match string from conftest.py's `matrixfilter` warning filter.
1 parent 78b3349 commit 2224ea5

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

control/tests/iosys_test.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"""
1010

1111
from __future__ import print_function
12+
import re
1213

1314
import numpy as np
1415
import pytest
@@ -1437,7 +1438,13 @@ def test_interconnect_unused_input():
14371438
connections=False)
14381439

14391440
#https://docs.pytest.org/en/6.2.x/warnings.html#recwarn
1440-
assert not record
1441+
for r in record:
1442+
# strip out matrix warnings
1443+
if re.match(r'.*matrix subclass', str(r.message)):
1444+
continue
1445+
print(r.message)
1446+
pytest.fail(f'Unexpected warning: {r.message}')
1447+
14411448

14421449
# warn if explicity ignored input in fact used
14431450
with pytest.warns(UserWarning, match=r"Input\(s\) specified as ignored is \(are\) used:") as record:
@@ -1481,7 +1488,6 @@ def test_interconnect_unused_output():
14811488
h = ct.interconnect([g,s,k],
14821489
inputs=['r'],
14831490
outputs=['y'])
1484-
print(record.list[0])
14851491

14861492

14871493
# no warning if output explicitly ignored
@@ -1501,7 +1507,12 @@ def test_interconnect_unused_output():
15011507
connections=False)
15021508

15031509
#https://docs.pytest.org/en/6.2.x/warnings.html#recwarn
1504-
assert not record
1510+
for r in record:
1511+
# strip out matrix warnings
1512+
if re.match(r'.*matrix subclass', str(r.message)):
1513+
continue
1514+
print(r.message)
1515+
pytest.fail(f'Unexpected warning: {r.message}')
15051516

15061517
# warn if explicity ignored output in fact used
15071518
with pytest.warns(UserWarning, match=r"Output\(s\) specified as ignored is \(are\) used:"):

0 commit comments

Comments
 (0)