@@ -617,6 +617,53 @@ class A:
617617 with self .assertRaises (TypeError ):
618618 type .__setattr__ (A , b'x' , None )
619619
620+ # TODO: RUSTPYTHON
621+ @unittest .expectedFailure
622+ def testTypeAttributeAccessErrorMessages (self ):
623+ class A :
624+ pass
625+
626+ error_msg = "type object 'A' has no attribute 'x'"
627+ with self .assertRaisesRegex (AttributeError , error_msg ):
628+ A .x
629+ with self .assertRaisesRegex (AttributeError , error_msg ):
630+ del A .x
631+
632+ # TODO: RUSTPYTHON
633+ @unittest .expectedFailure
634+ def testObjectAttributeAccessErrorMessages (self ):
635+ class A :
636+ pass
637+ class B :
638+ y = 0
639+ __slots__ = ('z' ,)
640+
641+ error_msg = "'A' object has no attribute 'x'"
642+ with self .assertRaisesRegex (AttributeError , error_msg ):
643+ A ().x
644+ with self .assertRaisesRegex (AttributeError , error_msg ):
645+ del A ().x
646+
647+ error_msg = "'B' object has no attribute 'x'"
648+ with self .assertRaisesRegex (AttributeError , error_msg ):
649+ B ().x
650+ with self .assertRaisesRegex (AttributeError , error_msg ):
651+ del B ().x
652+ with self .assertRaisesRegex (AttributeError , error_msg ):
653+ B ().x = 0
654+
655+ error_msg = "'B' object attribute 'y' is read-only"
656+ with self .assertRaisesRegex (AttributeError , error_msg ):
657+ del B ().y
658+ with self .assertRaisesRegex (AttributeError , error_msg ):
659+ B ().y = 0
660+
661+ error_msg = 'z'
662+ with self .assertRaisesRegex (AttributeError , error_msg ):
663+ B ().z
664+ with self .assertRaisesRegex (AttributeError , error_msg ):
665+ del B ().z
666+
620667 # TODO: RUSTPYTHON
621668 @unittest .expectedFailure
622669 def testConstructorErrorMessages (self ):
@@ -674,5 +721,23 @@ def __init__(self, *args, **kwargs):
674721 with self .assertRaisesRegex (TypeError , error_msg ):
675722 object .__init__ (E (), 42 )
676723
724+ def testClassWithExtCall (self ):
725+ class Meta (int ):
726+ def __init__ (* args , ** kwargs ):
727+ pass
728+
729+ def __new__ (cls , name , bases , attrs , ** kwargs ):
730+ return bases , kwargs
731+
732+ d = {'metaclass' : Meta }
733+
734+ class A (** d ): pass
735+ self .assertEqual (A , ((), {}))
736+ class A (0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , ** d ): pass
737+ self .assertEqual (A , (tuple (range (8 )), {}))
738+ class A (0 , * range (1 , 8 ), ** d , foo = 'bar' ): pass
739+ self .assertEqual (A , (tuple (range (8 )), {'foo' : 'bar' }))
740+
741+
677742if __name__ == '__main__' :
678743 unittest .main ()
0 commit comments