diff --git a/mypyc/test-data/fixtures/testutil.py b/mypyc/test-data/fixtures/testutil.py index f210faf71109..36ec41c8f38b 100644 --- a/mypyc/test-data/fixtures/testutil.py +++ b/mypyc/test-data/fixtures/testutil.py @@ -45,7 +45,7 @@ def assertRaises(typ: type, msg: str = '') -> Iterator[None]: try: yield except Exception as e: - assert isinstance(e, typ), f"{e!r} is not a {typ.__name__}" + assert type(e) is typ, f"{e!r} is not a {typ.__name__}" assert msg in str(e), f'Message "{e}" does not match "{msg}"' else: assert False, f"Expected {typ.__name__} but got no exception" diff --git a/mypyc/test-data/run-i64.test b/mypyc/test-data/run-i64.test index 1a82ac3e2dd1..36567c949d79 100644 --- a/mypyc/test-data/run-i64.test +++ b/mypyc/test-data/run-i64.test @@ -1307,28 +1307,28 @@ def test_many_locals() -> None: a31: i64 = 31 a32: i64 = 32 a33: i64 = 33 - with assertRaises(NameError): + with assertRaises(UnboundLocalError): print(a0) - with assertRaises(NameError): + with assertRaises(UnboundLocalError): print(a31) - with assertRaises(NameError): + with assertRaises(UnboundLocalError): print(a32) - with assertRaises(NameError): + with assertRaises(UnboundLocalError): print(a33) a0 = 5 assert a0 == 5 - with assertRaises(NameError): + with assertRaises(UnboundLocalError): print(a31) - with assertRaises(NameError): + with assertRaises(UnboundLocalError): print(a32) - with assertRaises(NameError): + with assertRaises(UnboundLocalError): print(a33) a32 = 55 assert a0 == 5 assert a32 == 55 - with assertRaises(NameError): + with assertRaises(UnboundLocalError): print(a31) - with assertRaises(NameError): + with assertRaises(UnboundLocalError): print(a33) a31 = 10 a33 = 20 diff --git a/mypyc/test-data/run-misc.test b/mypyc/test-data/run-misc.test index f07ac51dae6c..2252f3aa104a 100644 --- a/mypyc/test-data/run-misc.test +++ b/mypyc/test-data/run-misc.test @@ -37,9 +37,9 @@ from testutil import assertRaises f(True, True) f(False, False) -with assertRaises(NameError): +with assertRaises(UnboundLocalError): f(False, True) -with assertRaises(NameError): +with assertRaises(UnboundLocalError): g() [out] lol diff --git a/mypyc/test-data/run-primitives.test b/mypyc/test-data/run-primitives.test index b95f742977be..694700d4738c 100644 --- a/mypyc/test-data/run-primitives.test +++ b/mypyc/test-data/run-primitives.test @@ -345,10 +345,10 @@ delAttribute() delAttributeMultiple() with assertRaises(AttributeError): native.global_var -with assertRaises(NameError, 'local variable "dummy" referenced before assignment'): +with assertRaises(UnboundLocalError, 'local variable "dummy" referenced before assignment'): delLocal(True) assert delLocal(False) == 10 -with assertRaises(NameError, 'local variable "dummy" referenced before assignment'): +with assertRaises(UnboundLocalError, 'local variable "dummy" referenced before assignment'): delLocalLoop() [out] (1, 2, 3)