v1 = a[s1]
v2 = a[s2]
with self.assertRaisesRegex(ValueError,
- regex=r"^Array can no longer be mutated after it was indexed with a value at "):
+ r"^Array can no longer be mutated after it was indexed with a value at "):
a[1] = 2
with self.assertRaisesRegex(ValueError,
- regex=r"^Array can no longer be mutated after it was indexed with a value at "):
+ r"^Array can no longer be mutated after it was indexed with a value at "):
del a[1]
with self.assertRaisesRegex(ValueError,
- regex=r"^Array can no longer be mutated after it was indexed with a value at "):
+ r"^Array can no longer be mutated after it was indexed with a value at "):
a.insert(1, 2)
def test_repr(self):
def process():
nonlocal survived
with self.assertRaisesRegex(TypeError,
- regex=r"Received unsupported command 1 from process .+?"):
+ r"Received unsupported command 1 from process .+?"):
yield 1
yield Settle()
survived = True
sim.add_clock(1e-6)
sim.run_until(1e-5)
with self.assertRaisesRegex(ValueError,
- regex=r"^Cannot start writing waveforms after advancing simulation time$"):
+ r"^Cannot start writing waveforms after advancing simulation time$"):
with sim.write_vcd(open(os.path.devnull, "wt")):
pass
sim = Simulator(m)
sim.add_clock(1e-6)
with self.assertRaisesRegex(ValueError,
- regex=r"^Already writing waveforms to .+$"):
+ r"^Already writing waveforms to .+$"):
with sim.write_vcd(open(os.path.devnull, "wt")):
with sim.write_vcd(open(os.path.devnull, "wt")):
pass
# WTF? unittest.assertRaises is completely broken.
self.assertEqual(str(cm.exception), msg)
- @contextmanager
- def assertRaisesRegex(self, exception, regex=None):
- with super().assertRaises(exception) as cm:
- yield
- if regex is not None:
- # unittest.assertRaisesRegex also seems broken...
- self.assertRegex(str(cm.exception), regex)
-
@contextmanager
def assertWarns(self, category, msg=None):
with warnings.catch_warnings(record=True) as warns: