summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_contextlib.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-35202: Remove unused imports in Lib directory (GH-10450)Srinivas Thatiparthy (శ్రీనివాస్ తాటిపర్తి)2018-11-151-1/+0
|
* bpo-30306: release arguments of contextmanager (GH-1500)Martin Teichmann2018-01-281-0/+47
| | | | | | | | | | | | | | | | The arguments to a generator function which is declared as a contextmanager are stored inside the context manager, and thus are kept alive, even when it is used as a regular context manager, and not as a function decorator (where it needs the original arguments to recreate the generator on each call). This is a possible unnecessary memory leak, so this changes contextmanager.__enter__ to release the saved arguments, as that method being called means that particular CM instance isn't going to need to recreate the underlying generator. Patch by Martin Teichmann.
* bpo-29302: Implement contextlib.AsyncExitStack. (#4790)Ilya Kulakov2018-01-251-34/+38
|
* bpo-10049: Add a "no-op" (null) context manager to contextlib (GH-4464)Jesse-Bakker2017-11-231-0/+10
| | | | | Adds a simpler and faster alternative to ExitStack for handling single optional context managers without having to change the lexical structure of your code.
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-5/+1
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* bpo-30266: support "= None" pattern in AbstractContextManager (#1448)Jelle Zijlstra2017-06-091-0/+10
| | | | | contextlib.AbstractContextManager now supports anti-registration by setting __enter__ = None or __exit__ = None, following the pattern introduced in bpo-25958.
* bpo-29692: contextlib.contextmanager may incorrectly unchain RuntimeError ↵svelankar2017-04-111-0/+23
| | | | | | | | | | (GH-949) contextlib._GeneratorContextManager.__exit__ includes a special case to deal with PEP 479 RuntimeErrors created when `StopIteration` is thrown into the context manager body. Previously this check was too permissive, and undid one level of chaining on *all* RuntimeError instances, not just those that wrapped a StopIteration instance.
* Added more tests for issue #27122.Serhiy Storchaka2016-06-201-5/+11
|\
| * Added more tests for issue #27122.Serhiy Storchaka2016-06-201-5/+11
| |
* | Issue #27123: When an exception is raised within the context beingGregory P. Smith2016-06-141-0/+28
|\ \ | |/ | | | | | | | | | | managed by a contextlib.ExitStack() and one of the exit stack generators catches and raises it in a chain, do not re-raise the original exception when exiting, let the new chained one through. This avoids the PEP 479 bug described in issue25782.
| * Issue #27123: When an exception is raised within the context beingGregory P. Smith2016-06-141-0/+28
| | | | | | | | | | | | | | managed by a contextlib.ExitStack() and one of the exit stack generators catches and raises it in a chain, do not re-raise the original exception when exiting, let the new chained one through. This avoids the PEP 479 bug described in issue25782.
* | Issue #25609: Introduce contextlib.AbstractContextManager andBrett Cannon2016-04-081-0/+33
| | | | | | | | typing.ContextManager.
* | Issue #26136: Upgrade the generator_stop warning to DeprecationWarningMartin Panter2016-02-101-1/+1
|/ | | | Patch by Anish Shah.
* Issue #25322: Merge contextlib.suppress test fix from 3.4 into 3.5Martin Panter2015-10-101-1/+3
|\
| * Issue #25322: Fix test for nested contextlib.suppressMartin Panter2015-10-101-1/+3
| |
* | Issue #24336: The contextmanager decorator now works with functions withSerhiy Storchaka2015-06-281-0/+8
|\ \ | |/ | | | | keyword arguments called "func" and "self". Patch by Martin Panter.
| * Issue #24336: The contextmanager decorator now works with functions withSerhiy Storchaka2015-06-281-0/+8
| | | | | | | | keyword arguments called "func" and "self". Patch by Martin Panter.
* | Issue 24237: Raise PendingDeprecationWarning per PEP 479Yury Selivanov2015-05-221-2/+4
| | | | | | | | | | | | | | | | | | Raise PendingDeprecationWarning when generator raises StopIteration and no __future__ import is used. Fix offenders in the stdlib and tests. See also issue 22906. Thanks to Nick Coghlan and Berker Peksag for reviews.
* | PEP 479: Change StopIteration handling inside generators.Yury Selivanov2015-05-091-0/+34
| | | | | | | | Closes issue #22906.
* | Issue #22389: Add contextlib.redirect_stderr().Berker Peksag2014-11-281-21/+37
|/
* Merge removal of issue 20317 debugging code from 3.3Nick Coghlan2014-01-241-10/+48
|\
| * Issue 20317: Remove debugging code from contextlibNick Coghlan2014-01-241-10/+48
| | | | | | | | | | | | | | - Alex J Burke noticed a debugging raise in the commit that fixed the original bug reported in issue 20317 - this showed that multiple iterations through the affected loop wasn't actually being tested
* | Merge #20317 from 3.3Nick Coghlan2014-01-221-0/+23
|\ \ | |/
| * Issue #20317: Don't create a reference loop in ExitStackNick Coghlan2014-01-221-0/+23
| |
* | Close #19403: make contextlib.redirect_stdout reentrantNick Coghlan2013-11-031-7/+17
| |
* | Issue #19330: Handle the no-docstrings case in testsNick Coghlan2013-10-261-16/+12
| |
* | Close #19330 by using public classes in contextlibNick Coghlan2013-10-261-5/+58
| | | | | | | | | | | | | | - added test cases to ensure docstrings are reasonable - also updates various comments in contextlib for accuracy - identifed #19404 as an issue making it difficult to provide good help output on generator based context manager instances
* | Close #19396: make test_contextlib tolerate -SNick Coghlan2013-10-261-3/+4
| |
* | contextlib doc updates and refactoringNick Coghlan2013-10-191-4/+44
| | | | | | | | | | | | | | | | | | | | | | - explain single use, reusable and reentrant in docs - converted suppress to a reentrant class based impl - converted redirect_stdout to a reusable impl - moved both suppress and redirect_stdout behind a functional facade - added reentrancy tests for the updated suppress - added reusability tests for the updated redirect_stdio - slightly cleaned up an exception from contextmanager
* | Close #19266: contextlib.ignore -> contextlib.suppressNick Coghlan2013-10-171-14/+14
| | | | | | | | Patch by Zero Piraeus.
* | Rename contextlib.ignored() to contextlib.ignore().Raymond Hettinger2013-10-111-5/+5
| |
* | Issue #15805: Add contextlib.redirect_stdout()Raymond Hettinger2013-10-101-0/+9
| |
* | Merge #19092 from 3.3Nick Coghlan2013-10-011-0/+37
|\ \ | |/
| * Close #19092: ExitStack now reraises exceptions from __exit__Nick Coghlan2013-10-011-0/+37
| | | | | | | | Report and patch by Hrvoje Nikšić
* | Update various test modules to use unittest.main() for test discoveryBrett Cannon2013-06-131-5/+1
| | | | | | | | instead of manually listing tests for test.support.run_unittest().
* | Issue #15806: Add contextlib.ignored().Raymond Hettinger2013-03-111-0/+22
|/
* Close #14969: Improve the handling of exception chaining in contextlib.ExitStackNick Coghlan2012-06-011-11/+18
|
* Close #14963: Use an iterative algorithm in contextlib.ExitStack.__exit__ ↵Nick Coghlan2012-05-311-0/+6
| | | | (Patch by Alon Horev)
* Issue #14963: Added test cases for contextlib.ExitStack exception handling ↵Nick Coghlan2012-05-311-0/+89
| | | | behaviour (Initial patch by Alon Horev)
* Close #13585: add contextlib.ExitStack to replace the ill-fated ↵Nick Coghlan2012-05-211-0/+123
| | | | contextlib.nested API
* Issue #11647: allow contextmanager objects to be used as decorators as ↵Nick Coghlan2011-05-051-1/+6
| | | | described in the docs. Initial patch by Ysj Ray.
* #10273: Rename assertRegexpMatches and assertRaisesRegexp to assertRegex and ↵Ezio Melotti2010-12-011-2/+2
| | | | assertRaisesRegex.
* Issue 9110. Adding ContextDecorator to contextlib. This enables the creation ↵Michael Foord2010-06-301-0/+163
| | | | of APIs that act as decorators as well as context managers. contextlib.contextmanager changed to use ContextDecorator.
* Merged revisions 80552-80556,80564-80566,80568-80571 via svnmerge fromVictor Stinner2010-04-281-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r80552 | victor.stinner | 2010-04-27 23:46:03 +0200 (mar., 27 avril 2010) | 3 lines Issue #7449, part 1: fix test_support.py for Python compiled without thread ........ r80553 | victor.stinner | 2010-04-27 23:47:01 +0200 (mar., 27 avril 2010) | 1 line Issue #7449, part 2: regrtest.py -j option requires thread support ........ r80554 | victor.stinner | 2010-04-27 23:51:26 +0200 (mar., 27 avril 2010) | 9 lines Issue #7449 part 3, test_doctest: import trace module in test_coverage() Import trace module fail if the threading module is missing. test_coverage() is only used if test_doctest.py is used with the -c option. This commit allows to execute the test suite without thread support. Move "import trace" in test_coverage() and use test_support.import_module('trace'). ........ r80555 | victor.stinner | 2010-04-27 23:56:26 +0200 (mar., 27 avril 2010) | 6 lines Issue #7449, part 4: skip test_multiprocessing if thread support is disabled import threading after _multiprocessing to raise a more revelant error message: "No module named _multiprocessing". _multiprocessing is not compiled without thread support. ........ r80556 | victor.stinner | 2010-04-28 00:01:24 +0200 (mer., 28 avril 2010) | 8 lines Issue #7449, part 5: split Test.test_open() of ctypes/test/test_errno.py * Split Test.test_open() in 2 functions: test_open() and test_thread_open() * Skip test_open() and test_thread_open() if we are unable to find the C library * Skip test_thread_open() if thread support is disabled * Use unittest.skipUnless(os.name == "nt", ...) on test_GetLastError() ........ r80564 | victor.stinner | 2010-04-28 00:59:35 +0200 (mer., 28 avril 2010) | 4 lines Issue #7449, part 6: fix test_hashlib for missing threading module Move @test_support.reap_thread decorator from test_main() to test_threaded_hashing(). ........ r80565 | victor.stinner | 2010-04-28 01:01:29 +0200 (mer., 28 avril 2010) | 6 lines Issue #7449, part 7: simplify threading detection in test_capi * Skip TestPendingCalls if threading module is missing * Test if threading module is present or not, instead of test the presence of _testcapi._test_thread_state ........ r80566 | victor.stinner | 2010-04-28 01:03:16 +0200 (mer., 28 avril 2010) | 4 lines Issue #7449, part 8: don't skip the whole test_asynchat if threading is missing TestFifo can be executed without the threading module ........ r80568 | victor.stinner | 2010-04-28 01:14:58 +0200 (mer., 28 avril 2010) | 6 lines Issue #7449, part 9: fix test_xmlrpclib for missing threading module * Skip testcases using threads if threading module is missing * Use "http://" instead of URL in ServerProxyTestCase if threading is missing because URL is not set in this case ........ r80569 | victor.stinner | 2010-04-28 01:33:58 +0200 (mer., 28 avril 2010) | 6 lines Partial revert of r80556 (Issue #7449, part 5, fix ctypes test) Rewrite r80556: the thread test have to be executed just after the test on libc_open() and so the test cannot be splitted in two functions (without duplicating code, and I don't want to duplicate code). ........ r80570 | victor.stinner | 2010-04-28 01:51:16 +0200 (mer., 28 avril 2010) | 8 lines Issue #7449, part 10: test_cmd imports trace module using test_support.import_module() Use test_support.import_module() instead of import to raise a SkipTest exception if the import fail. Import trace fails if the threading module is missing. See also part 3: test_doctest: import trace module in test_coverage(). ........ r80571 | victor.stinner | 2010-04-28 01:55:59 +0200 (mer., 28 avril 2010) | 6 lines Issue #7449, last part (11): fix many tests if thread support is disabled * Use try/except ImportError or test_support.import_module() to import thread and threading modules * Add @unittest.skipUnless(threading, ...) to testcases using threads ........
* (partially)Florent Xicluna2010-04-021-29/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | Merged revisions 79534,79537,79539,79558,79606 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r79534 | florent.xicluna | 2010-03-31 23:21:54 +0200 (mer, 31 mar 2010) | 2 lines Fix test for xml.etree when using a non-ascii path. And use check_warnings instead of catch_warnings. ........ r79537 | florent.xicluna | 2010-03-31 23:40:32 +0200 (mer, 31 mar 2010) | 2 lines Fix typo ........ r79539 | florent.xicluna | 2010-04-01 00:01:03 +0200 (jeu, 01 avr 2010) | 2 lines Replace catch_warnings with check_warnings when it makes sense. Use assertRaises context manager to simplify some tests. ........ r79558 | florent.xicluna | 2010-04-01 20:17:09 +0200 (jeu, 01 avr 2010) | 2 lines #7092: Fix some -3 warnings, and fix Lib/platform.py when the path contains a double-quote. ........ r79606 | florent.xicluna | 2010-04-02 19:26:42 +0200 (ven, 02 avr 2010) | 2 lines Backport some robotparser test and skip the test if the external resource is not available. ........
* Merged revisions 78093 via svnmerge fromGeorg Brandl2010-03-141-2/+0
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r78093 | georg.brandl | 2010-02-07 18:03:15 +0100 (So, 07 Feb 2010) | 1 line Remove unused imports in test modules. ........
* Merged revisions 78351 via svnmerge fromR. David Murray2010-02-241-1/+11
| | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r78351 | r.david.murray | 2010-02-22 19:24:49 -0500 (Mon, 22 Feb 2010) | 5 lines Issue 6292: for the moment at least, the test suite passes if run with -OO. Tests requiring docstrings are skipped. Patch by Brian Curtin, thanks to Matias Torchinsky for helping review and improve the patch. ........
* remove warnings supressionBenjamin Peterson2009-07-011-4/+1
|
* Removed contextlib.nested()Raymond Hettinger2009-07-011-122/+0
|
* convert old fail* assertions to assert*Benjamin Peterson2009-06-301-10/+10
|