|
|
|
@ -109,7 +109,7 @@ class FailureTestCase(unittest.TestCase): |
|
|
|
with foo: pass |
|
|
|
self.assertRaises(NameError, fooNotDeclared) |
|
|
|
|
|
|
|
def testEnterAttributeError(self): |
|
|
|
def testEnterAttributeError1(self): |
|
|
|
class LacksEnter(object): |
|
|
|
def __exit__(self, type, value, traceback): |
|
|
|
pass |
|
|
|
@ -117,7 +117,16 @@ class FailureTestCase(unittest.TestCase): |
|
|
|
def fooLacksEnter(): |
|
|
|
foo = LacksEnter() |
|
|
|
with foo: pass |
|
|
|
self.assertRaises(AttributeError, fooLacksEnter) |
|
|
|
self.assertRaisesRegexp(AttributeError, '__enter__', fooLacksEnter) |
|
|
|
|
|
|
|
def testEnterAttributeError2(self): |
|
|
|
class LacksEnterAndExit(object): |
|
|
|
pass |
|
|
|
|
|
|
|
def fooLacksEnterAndExit(): |
|
|
|
foo = LacksEnterAndExit() |
|
|
|
with foo: pass |
|
|
|
self.assertRaisesRegexp(AttributeError, '__enter__', fooLacksEnterAndExit) |
|
|
|
|
|
|
|
def testExitAttributeError(self): |
|
|
|
class LacksExit(object): |
|
|
|
@ -127,7 +136,7 @@ class FailureTestCase(unittest.TestCase): |
|
|
|
def fooLacksExit(): |
|
|
|
foo = LacksExit() |
|
|
|
with foo: pass |
|
|
|
self.assertRaises(AttributeError, fooLacksExit) |
|
|
|
self.assertRaisesRegexp(AttributeError, '__exit__', fooLacksExit) |
|
|
|
|
|
|
|
def assertRaisesSyntaxError(self, codestr): |
|
|
|
def shouldRaiseSyntaxError(s): |
|
|
|
|