summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_contextlib.py
Commit message (Collapse)AuthorAgeFilesLines
* Standardize on test.test_support.run_unittest() (as opposed to a mix of ↵Collin Winter2007-04-251-4/+2
| | | | run_unittest() and run_suite()). Also, add functionality to run_unittest() that admits usage of unittest.TestLoader.loadTestsFromModule().
* Remove the old decimal context management tests from test_contextlib (guess ↵Nick Coghlan2006-08-311-26/+0
| | | | who didn't run the test suite before committing...)
* Finish bringing SVN into line with latest version of PEP 343 by getting rid ↵Nick Coghlan2006-05-031-25/+25
| | | | 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()
* Get rid of __context__, per the latest changes to PEP 343 and python-devGuido van Rossum2006-05-021-6/+4
| | | | | | | | discussion. There are two places of documentation that still mention __context__: Doc/lib/libstdtypes.tex -- I wasn't quite sure how to rewrite that without spending a whole lot of time thinking about it; and whatsnew, which Andrew usually likes to change himself.
* Move the PEP 343 documentation and implementation closer to theNick Coghlan2006-04-251-23/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | terminology in the alpha 1 documentation. - "context manager" reverts to its alpha 1 definition - the term "context specifier" goes away entirely - contextlib.GeneratorContextManager is renamed GeneratorContext There are still a number of changes relative to alpha 1: - the expression in the with statement is explicitly called the "context expression" in the language reference - the terms 'with statement context', 'context object' or 'with statement context' are used in several places instead of a bare 'context'. The aim of this is to avoid ambiguity in relation to the runtime context set up when the block is executed, and the context objects that already exist in various application domains (such as decimal.Context) - contextlib.contextmanager is renamed to contextfactory This best reflects the nature of the function resulting from the use of that decorator - decimal.ContextManager is renamed to WithStatementContext Simple dropping the 'Manager' part wasn't possible due to the fact that decimal.Context already exists and means something different. WithStatementContext is ugly but workable. A technically unrelated change snuck into this commit: contextlib.closing now avoids the overhead of creating a generator, since it's trivial to implement that particular context manager directly.
* Fix broken contextlib test from last checkin (I'd've sworn I tested that ↵Nick Coghlan2006-04-241-0/+2
| | | | before checking it in. . .)
* Fix contextlib.nested to cope with exit methods raising and handling exceptionsNick Coghlan2006-04-241-0/+23
|
* DecimalContextTestCase: this permanently changed theTim Peters2006-04-101-9/+13
| | | | | | default decimal context, causing test_tokenize to fail if it ran after test_contextlib. Changed to restore the decimal context in effect at the test's start.
* test_contextlib wasn't actually being run by regrtest.py. Or more precisely,Phillip J. Eby2006-04-101-1/+9
| | | | it was being run, but no tests were actually executed!
* Fix contextlib not copying function attributesPhillip J. Eby2006-03-281-0/+15
|
* Fix a problem with @contextmanager not detecting a broken generatorPhillip J. Eby2006-03-251-0/+22
| | | | | | that yields after a throw(). Make @contextmanager not reraise exceptions, but return a false value in that case instead. Add test cases for both behaviors.
* Fix a bug in nested() - if one of the sub-context-managers swallows theGuido van Rossum2006-03-011-0/+54
| | | | exception, it should not be propagated up. With unit tests.
* Updates to the with-statement:Guido van Rossum2006-02-281-0/+240
- New semantics for __exit__() -- it must re-raise the exception if type is not None; the with-statement itself doesn't do this. (See the updated PEP for motivation.) - Added context managers to: - file - thread.LockType - threading.{Lock,RLock,Condition,Semaphore,BoundedSemaphore} - decimal.Context - Added contextlib.py, which defines @contextmanager, nested(), closing(). - Unit tests all around; bot no docs yet.