@@ -109,15 +109,24 @@ def fooNotDeclared():
109109 with foo : pass
110110 self .assertRaises (NameError , fooNotDeclared )
111111
112- def testEnterAttributeError (self ):
112+ def testEnterAttributeError1 (self ):
113113 class LacksEnter (object ):
114114 def __exit__ (self , type , value , traceback ):
115115 pass
116116
117117 def fooLacksEnter ():
118118 foo = LacksEnter ()
119119 with foo : pass
120- self .assertRaises (AttributeError , fooLacksEnter )
120+ self .assertRaisesRegexp (AttributeError , '__enter__' , fooLacksEnter )
121+
122+ def testEnterAttributeError2 (self ):
123+ class LacksEnterAndExit (object ):
124+ pass
125+
126+ def fooLacksEnterAndExit ():
127+ foo = LacksEnterAndExit ()
128+ with foo : pass
129+ self .assertRaisesRegexp (AttributeError , '__enter__' , fooLacksEnterAndExit )
121130
122131 def testExitAttributeError (self ):
123132 class LacksExit (object ):
@@ -127,7 +136,7 @@ def __enter__(self):
127136 def fooLacksExit ():
128137 foo = LacksExit ()
129138 with foo : pass
130- self .assertRaises (AttributeError , fooLacksExit )
139+ self .assertRaisesRegexp (AttributeError , '__exit__' , fooLacksExit )
131140
132141 def assertRaisesSyntaxError (self , codestr ):
133142 def shouldRaiseSyntaxError (s ):
0 commit comments