diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2006-05-03 13:02:47 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2006-05-03 13:02:47 (GMT) |
commit | afd5e63e243b600e5344a34760d9e6565dafe1a9 (patch) | |
tree | 6fdd6c7dd056fd5d4ce1e67e7d0b430b374dd270 /Lib/test/test_with.py | |
parent | 1b06a1d4e30729434630e9fa37b041926a5766f3 (diff) | |
download | cpython-afd5e63e243b600e5344a34760d9e6565dafe1a9.zip cpython-afd5e63e243b600e5344a34760d9e6565dafe1a9.tar.gz cpython-afd5e63e243b600e5344a34760d9e6565dafe1a9.tar.bz2 |
Finish bringing SVN into line with latest version of PEP 343 by getting rid of all remaining references to context objects that I could find. Without a __context__() method context objects no longer exist. Also get test_with working again, and adopt a suggestion from Neal for decimal.Context.get_manager()
Diffstat (limited to 'Lib/test/test_with.py')
-rw-r--r-- | Lib/test/test_with.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py index 765bfec..5750508 100644 --- a/Lib/test/test_with.py +++ b/Lib/test/test_with.py @@ -10,25 +10,26 @@ __email__ = "mbland at acm dot org" import sys import unittest from collections import deque -from contextlib import GeneratorContext, contextfactory +from contextlib import GeneratorContextManager, contextmanager from test.test_support import run_unittest -class MockContextManager(GeneratorContext): +class MockContextManager(GeneratorContextManager): def __init__(self, gen): - GeneratorContext.__init__(self, gen) + GeneratorContextManager.__init__(self, gen) self.enter_called = False self.exit_called = False self.exit_args = None def __enter__(self): self.enter_called = True - return GeneratorContext.__enter__(self) + return GeneratorContextManager.__enter__(self) def __exit__(self, type, value, traceback): self.exit_called = True self.exit_args = (type, value, traceback) - return GeneratorContext.__exit__(self, type, value, traceback) + return GeneratorContextManager.__exit__(self, type, + value, traceback) def mock_contextmanager(func): @@ -439,7 +440,7 @@ class ExceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin): self.assertAfterWithGeneratorInvariantsNoError(self.bar) def testRaisedStopIteration1(self): - @contextfactory + @contextmanager def cm(): yield @@ -463,7 +464,7 @@ class ExceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin): self.assertRaises(StopIteration, shouldThrow) def testRaisedGeneratorExit1(self): - @contextfactory + @contextmanager def cm(): yield |