66from guppylang import GuppyWarning
77from guppylang_internals .error import GuppyError
88from guppylang .std .quantum import discard , h
9- from tests .util import compile_guppy
9+ from tests .util import compile_guppy , guppy_warning_records
1010
1111
1212def assert_unreachable_warning_emitted (fn ):
@@ -16,8 +16,9 @@ def assert_unreachable_warning_emitted(fn):
1616 warnings .simplefilter ("always" )
1717 result = fn ()
1818
19- assert len (records ) == 1
20- warning = records [0 ]
19+ guppy_records = guppy_warning_records (records )
20+ assert len (guppy_records ) == 1
21+ warning = guppy_records [0 ]
2122 assert warning .category is GuppyWarning
2223 assert str (warning .message ) == "Unreachable: This code is not reachable"
2324 return result
@@ -166,8 +167,9 @@ def test() -> int:
166167 return 1
167168 return 0
168169
169- assert len (records ) == 1
170- warning = records [0 ]
170+ guppy_records = guppy_warning_records (records )
171+ assert len (guppy_records ) == 1
172+ warning = guppy_records [0 ]
171173 assert warning .category is GuppyWarning
172174 assert warning .filename .endswith ("test_unreachable.py" )
173175 assert str (warning .message ) == "Unreachable: This code is not reachable"
@@ -185,8 +187,9 @@ def test() -> int:
185187 x = 1
186188 return x
187189
188- assert len (records ) == 1
189- warning = records [0 ]
190+ guppy_records = guppy_warning_records (records )
191+ assert len (guppy_records ) == 1
192+ warning = guppy_records [0 ]
190193 assert warning .category is GuppyWarning
191194 assert warning .filename .endswith ("test_unreachable.py" )
192195 assert str (warning .message ) == "Unreachable: This code is not reachable"
@@ -205,4 +208,5 @@ def test() -> int:
205208 return 1.0
206209 return 0
207210
208- assert len (records ) == 0
211+ guppy_records = guppy_warning_records (records )
212+ assert len (guppy_records ) == 0
0 commit comments