@@ -866,7 +866,7 @@ def test_bitmap_is_cleared_when_object_is_reused() -> None:
866866 list(gen(True))
867867
868868 # Ensure bitmap has been cleared.
869- with assertRaises(AttributeError): # TODO: Should be UnboundLocalError
869+ with assertRaises(UnboundLocalError):
870870 list(gen(False))
871871
872872def gen2(set: bool) -> Iterator[int]:
@@ -878,7 +878,7 @@ def gen2(set: bool) -> Iterator[int]:
878878def test_undefined_int_in_environment() -> None:
879879 list(gen2(True))
880880
881- with assertRaises(AttributeError): # TODO: Should be UnboundLocalError
881+ with assertRaises(UnboundLocalError):
882882 list(gen2(False))
883883
884884[case testVariableWithSameNameAsHelperMethod]
@@ -902,10 +902,9 @@ def test_same_names() -> None:
902902 assert list(gen_send()) == [2]
903903 assert list(gen_throw()) == [84]
904904
905- with assertRaises(AttributeError, "attribute 'send' of 'undefined_gen' undefined"):
906- # TODO: Should be UnboundLocalError, this test verifies that the attribute name
907- # matches the variable name in the input code, since internally it's generated
908- # with a prefix.
905+ with assertRaises(UnboundLocalError, "local variable 'send' referenced before assignment"):
906+ # this test verifies that the attribute name matches the variable name
907+ # in the input code, since internally it's generated with a prefix.
909908 list(undefined())
910909
911910[case testGeneratorInheritance]
0 commit comments