Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_with.FailureTestCase Class Reference

List of all members.

Public Member Functions

def testNameError
def testEnterAttributeError
def testExitAttributeError
def assertRaisesSyntaxError
def testAssignmentToNoneError
def testAssignmentToEmptyTupleError
def testAssignmentToTupleOnlyContainingNoneError
def testAssignmentToTupleContainingNoneError
def testEnterThrows
def testExitThrows

Public Attributes

 foo

Detailed Description

Definition at line 109 of file test_with.py.


Member Function Documentation

Definition at line 135 of file test_with.py.

00135 
00136     def assertRaisesSyntaxError(self, codestr):
00137         def shouldRaiseSyntaxError(s):
00138             compile(s, '', 'single')
00139         self.assertRaises(SyntaxError, shouldRaiseSyntaxError, codestr)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 146 of file test_with.py.

00146 
00147     def testAssignmentToEmptyTupleError(self):
00148         self.assertRaisesSyntaxError(
00149             'with mock as ():\n'
00150             '  pass')

Here is the call graph for this function:

Definition at line 140 of file test_with.py.

00140 
00141     def testAssignmentToNoneError(self):
00142         self.assertRaisesSyntaxError('with mock as None:\n  pass')
00143         self.assertRaisesSyntaxError(
00144             'with mock as (None):\n'
00145             '  pass')

Here is the call graph for this function:

Definition at line 157 of file test_with.py.

00157 
00158     def testAssignmentToTupleContainingNoneError(self):
00159         self.assertRaisesSyntaxError(
00160             'with mock as (foo, None, bar):\n'
00161             '  pass')

Here is the call graph for this function:

Definition at line 151 of file test_with.py.

00151 
00152     def testAssignmentToTupleOnlyContainingNoneError(self):
00153         self.assertRaisesSyntaxError('with mock as None,:\n  pass')
00154         self.assertRaisesSyntaxError(
00155             'with mock as (None,):\n'
00156             '  pass')

Here is the call graph for this function:

Definition at line 115 of file test_with.py.

00115 
00116     def testEnterAttributeError(self):
00117         class LacksEnter(object):
00118             def __exit__(self, type, value, traceback):
00119                 pass
00120 
00121         def fooLacksEnter():
00122             foo = LacksEnter()
00123             with foo: pass
00124         self.assertRaises(AttributeError, fooLacksEnter)

Here is the call graph for this function:

Definition at line 162 of file test_with.py.

00162 
00163     def testEnterThrows(self):
00164         class EnterThrows(object):
00165             def __enter__(self):
00166                 raise RuntimeError("Enter threw")
00167             def __exit__(self, *args):
00168                 pass
00169 
00170         def shouldThrow():
00171             ct = EnterThrows()
00172             self.foo = None
00173             with ct as self.foo:
00174                 pass
00175         self.assertRaises(RuntimeError, shouldThrow)
00176         self.assertEqual(self.foo, None)

Here is the call graph for this function:

Definition at line 125 of file test_with.py.

00125 
00126     def testExitAttributeError(self):
00127         class LacksExit(object):
00128             def __enter__(self):
00129                 pass
00130 
00131         def fooLacksExit():
00132             foo = LacksExit()
00133             with foo: pass
00134         self.assertRaises(AttributeError, fooLacksExit)

Here is the call graph for this function:

Definition at line 177 of file test_with.py.

00177 
00178     def testExitThrows(self):
00179         class ExitThrows(object):
00180             def __enter__(self):
00181                 return
00182             def __exit__(self, *args):
00183                 raise RuntimeError(42)
00184         def shouldThrow():
00185             with ExitThrows():
00186                 pass
00187         self.assertRaises(RuntimeError, shouldThrow)

Here is the call graph for this function:

Definition at line 110 of file test_with.py.

00110 
00111     def testNameError(self):
00112         def fooNotDeclared():
00113             with foo: pass
00114         self.assertRaises(NameError, fooNotDeclared)

Here is the call graph for this function:


Member Data Documentation

Definition at line 171 of file test_with.py.


The documentation for this class was generated from the following file: