Skip to content

Commit fa1354c

Browse files
committed
Change gate library test to avoid pytest identification
1 parent db4e43b commit fa1354c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

test/calibration/test_setup_library.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from qiskit_experiments.framework.json import ExperimentEncoder, ExperimentDecoder
2626

2727

28-
class TestLibrary(FixedFrequencyTransmon):
28+
class MutableTestLibrary(FixedFrequencyTransmon):
2929
"""A subclass designed for test_hash_warn.
3030
3131
This class ensures that FixedFrequencyTransmon is preserved if anything goes wrong
@@ -197,26 +197,27 @@ def test_hash_warn(self):
197197
4. A warning is raised since the class definition has changed.
198198
"""
199199

200-
lib1 = TestLibrary()
200+
lib1 = MutableTestLibrary()
201201
lib_data = json.dumps(lib1, cls=ExperimentEncoder)
202202
lib2 = json.loads(lib_data, cls=ExperimentDecoder)
203203

204204
self.assertTrue(self._test_library_equivalence(lib1, lib2))
205205

206206
# stash method build schedules to avoid other tests from failing
207-
build_schedules = TestLibrary._build_schedules
207+
build_schedules = MutableTestLibrary._build_schedules
208208

209209
def _my_build_schedules():
210210
"""A dummy function to change the class behaviour."""
211211
pass
212212

213213
# Change the schedule behaviour
214-
TestLibrary._build_schedules = _my_build_schedules
214+
MutableTestLibrary._build_schedules = _my_build_schedules
215215

216216
with self.assertWarns(UserWarning):
217-
json.loads(lib_data, cls=ExperimentDecoder)
218-
219-
TestLibrary._build_schedules = build_schedules
217+
try:
218+
json.loads(lib_data, cls=ExperimentDecoder)
219+
finally:
220+
MutableTestLibrary._build_schedules = build_schedules
220221

221222
def _test_library_equivalence(self, lib1, lib2) -> bool:
222223
"""Test if libraries are equivalent.

0 commit comments

Comments
 (0)