Back to index

python3.2  3.2.2
Public Member Functions
test.test_with.AssignmentTargetTestCase Class Reference

List of all members.

Public Member Functions

def testSingleComplexTarget
def testMultipleComplexTargets

Detailed Description

Definition at line 603 of file test_with.py.


Member Function Documentation

Definition at line 622 of file test_with.py.

00622 
00623     def testMultipleComplexTargets(self):
00624         class C:
00625             def __enter__(self): return 1, 2, 3
00626             def __exit__(self, t, v, tb): pass
00627         targets = {1: [0, 1, 2]}
00628         with C() as (targets[1][0], targets[1][1], targets[1][2]):
00629             self.assertEqual(targets, {1: [1, 2, 3]})
00630         with C() as (list(targets.values())[0][2], list(targets.values())[0][1], list(targets.values())[0][0]):
00631             self.assertEqual(targets, {1: [3, 2, 1]})
00632         with C() as (targets[1], targets[2], targets[3]):
00633             self.assertEqual(targets, {1: 1, 2: 2, 3: 3})
00634         class B: pass
00635         blah = B()
00636         with C() as (blah.one, blah.two, blah.three):
00637             self.assertEqual(blah.one, 1)
00638             self.assertEqual(blah.two, 2)
00639             self.assertEqual(blah.three, 3)
00640 

Here is the call graph for this function:

Definition at line 605 of file test_with.py.

00605 
00606     def testSingleComplexTarget(self):
00607         targets = {1: [0, 1, 2]}
00608         with mock_contextmanager_generator() as targets[1][0]:
00609             self.assertEqual(list(targets.keys()), [1])
00610             self.assertEqual(targets[1][0].__class__, MockResource)
00611         with mock_contextmanager_generator() as list(targets.values())[0][1]:
00612             self.assertEqual(list(targets.keys()), [1])
00613             self.assertEqual(targets[1][1].__class__, MockResource)
00614         with mock_contextmanager_generator() as targets[2]:
00615             keys = list(targets.keys())
00616             keys.sort()
00617             self.assertEqual(keys, [1, 2])
00618         class C: pass
00619         blah = C()
00620         with mock_contextmanager_generator() as blah.foo:
00621             self.assertEqual(hasattr(blah, "foo"), True)

Here is the call graph for this function:


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