summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/case.py
Commit message (Collapse)AuthorAgeFilesLines
* Remove binding of captured exceptions when not used to reduce the chances of ↵Pablo Galindo2019-11-191-1/+1
| | | | | | | creating cycles (GH-17246) Capturing exceptions into names can lead to reference cycles though the __traceback__ attribute of the exceptions in some obscure cases that have been reported previously and fixed individually. As these variables are not used anyway, we can remove the binding to reduce the chances of creating reference cycles. See for example GH-13135
* bpo-34596: Fallback to a default reason when @unittest.skip is uncalled (#9082)Naitree Zhu2019-09-091-0/+5
| | | | | | | | * bpo-34596: Fallback to a default reason when @unittest.skip is uncalled * Change default reason to empty string * Fix rst formatting of NEWS entry
* [3.9] bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-12620)Serhiy Storchaka2019-06-051-18/+1
| | | Turn deprecation warnings added in 3.8 into TypeError.
* bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-13700)Serhiy Storchaka2019-06-011-27/+3
|
* bpo-32972: Async test case (GH-13386)Andrew Svetlov2019-05-291-4/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add explicit `asyncSetUp` and `asyncTearDown` methods. The rest is the same as for #13228 `AsyncTestCase` create a loop instance for every test for the sake of test isolation. Sometimes a loop shared between all tests can speed up tests execution time a lot but it requires control of closed resources after every test finish. Basically, it requires nested supervisors support that was discussed with @1st1 many times. Sorry, asyncio supervisors have no chance to land on Python 3.8. The PR intentionally does not provide API for changing the used event loop or getting the test loop: use `asyncio.set_event_loop_policy()` and `asyncio.get_event_loop()` instead. The PR adds four overridable methods to base `unittest.TestCase` class: ``` def _callSetUp(self): self.setUp() def _callTestMethod(self, method): method() def _callTearDown(self): self.tearDown() def _callCleanup(self, function, /, *args, **kwargs): function(*args, **kwargs) ``` It allows using asyncio facilities with minimal influence on the unittest code. The last but not least: the PR respects contextvars. The context variable installed by `asyncSetUp` is available on test, `tearDown` and a coroutine scheduled by `addCleanup`. https://bugs.python.org/issue32972
* bpo-36542: Allow to overwrite the signature for Python functions. (GH-12705)Serhiy Storchaka2019-05-061-1/+4
|
* Document that TestCase.assertCountEqual() can take iterables (GH-686)jkleint2019-04-231-3/+2
|
* bpo-36492: Deprecate passing some arguments as keyword arguments. (GH-12637)Serhiy Storchaka2019-04-011-3/+41
| | | | | | | | | | | | | | | | | | | | | | Deprecated passing the following arguments as keyword arguments: - "func" in functools.partialmethod(), weakref.finalize(), profile.Profile.runcall(), cProfile.Profile.runcall(), bdb.Bdb.runcall(), trace.Trace.runfunc() and curses.wrapper(). - "function" in unittest.addModuleCleanup() and unittest.TestCase.addCleanup(). - "fn" in the submit() method of concurrent.futures.ThreadPoolExecutor and concurrent.futures.ProcessPoolExecutor. - "callback" in contextlib.ExitStack.callback(), contextlib.AsyncExitStack.callback() and contextlib.AsyncExitStack.push_async_callback(). - "c" and "typeid" in the create() method of multiprocessing.managers.Server and multiprocessing.managers.SharedMemoryServer. - "obj" in weakref.finalize(). Also allowed to pass arbitrary keyword arguments (even "self" and "func") if the above arguments are passed as positional argument.
* bpo-24412: Adds cleanUps for setUpClass and setUpModule. (GH-9190)Lisa Roach2018-11-091-1/+45
|
* bpo-34900: Make TestCase.debug() work with subtests (GH-9707)Bruno Oliveira2018-10-121-1/+1
|
* bpo-34318: Convert deprecation warnings to errors in assertRaises() etc. ↵Serhiy Storchaka2018-08-191-7/+2
| | | | (GH-8623)
* Update TestCase.assertAlmostEqual and assertNotAlmostEqual docstrings. (GH-3998)Ron2017-10-181-2/+3
| | | | The word "difference" from missing the sentence. This clarifies that it compares the difference between the two objects.
* bpo-30397: Add re.Pattern and re.Match. (#1646)Serhiy Storchaka2017-10-041-2/+2
|
* bpo-30664: The description of a unittest subtest now preserves the (#2265)Serhiy Storchaka2017-06-231-2/+12
| | | | order of keyword arguments of TestCase.subTest().
* bpo-30190: improved error msg for assertAlmostEqual(delta=...) (#1331)Giampaolo Rodola2017-05-011-14/+21
| | | | | | | | | | | | * #30190 / unittest / assertAlmostEqual(delta=...) / error msg: show the difference between the 2 numbers in case of failure * safe_repr() diff * also show difference when passing 'places' argument * refactoring * update Misc/NEWS
* Fix ref cycles in TestCase.assertRaises() (#193)Victor Stinner2017-03-271-22/+30
| | | | bpo-23890: unittest.TestCase.assertRaises() now manually breaks a reference cycle to not keep objects alive longer than expected.
* Issue #25651: Allow falsy values to be used for msg parameter of subTest()Berker Peksag2016-09-211-2/+3
|
* Issue #27626: Spelling fixes in docs, comments and internal namesMartin Panter2016-07-281-2/+2
| | | | Based on patch by Ville Skyttä.
* Issue #26837: assertSequenceEqual() now correctly outputs non-stringifiedSerhiy Storchaka2016-04-251-3/+3
| | | | | differing items (like bytes in the -b mode). This affects assertListEqual() and assertTupleEqual().
* Issue #21112: Fix regression in unittest.expectedFailure on subclasses.Robert Collins2015-08-271-2/+5
|\ | | | | | | Patch from Berker Peksag.
| * Issue #21112: Fix regression in unittest.expectedFailure on subclasses.Robert Collins2015-08-271-2/+5
| | | | | | | | Patch from Berker Peksag.
| * Reverted issue #24134 changes (except new tests).Serhiy Storchaka2015-05-161-13/+11
| |
* | Issue #20362: Honour TestCase.longMessage correctly in assertRegex.Robert Collins2015-08-191-7/+11
| | | | | | | | Patch from Ilia Kurenkov.
* | Issue #15836: assertRaises(), assertRaisesRegex(), assertWarns() andSerhiy Storchaka2015-05-211-0/+13
| | | | | | | | | | assertWarnsRegex() assertments now check the type of the first argument to prevent possible user error. Based on patch by Daniel Wagner-Hall.
* | Issue #24134: assertRaises(), assertRaisesRegex(), assertWarns() andSerhiy Storchaka2015-05-161-44/+44
|/ | | | | assertWarnsRegex() checks now emits a deprecation warning when callable is None or keyword arguments except msg is passed in the context manager mode.
* Fixed English in error message.Serhiy Storchaka2015-05-061-1/+1
|
* Issue #24134: assertRaises(), assertRaisesRegex(), assertWarns() andSerhiy Storchaka2015-05-061-11/+13
| | | | | | assertWarnsRegex() checks are not longer successful if the callable is None. Added tests for assertRaises().
* Issue #21408: The default __ne__() now returns NotImplemented if __eq__()Serhiy Storchaka2015-01-261-3/+0
| | | | returned NotImplemented. Removed incorrect implementations of __ne__().
* Issue #9815: assertRaises now tries to clear references to local variables ↵Antoine Pitrou2014-04-281-0/+3
| | | | in the exception's traceback.
* backport: #20145: assert[Raises|Warns]Regex now raise TypeError on bad regex.R David Murray2014-03-251-1/+1
| | | | | | | Previously a non-string, non-regex second argument and missing callable argument could cause the test to appear to always pass. Initial patch by Kamilla Holanda.
* Close #19880: Fix a reference leak in unittest.TestCase. Explicitly breakVictor Stinner2013-12-091-1/+13
| | | | reference cycles between frames and the _Outcome instance.
* Issue #18996: TestCase.assertEqual() now more cleverly shorten differingSerhiy Storchaka2013-09-231-13/+7
| | | | strings in error report.
* Issue #18937: Add an assertLogs() context manager to unittest.TestCase to ↵Antoine Pitrou2013-09-141-6/+103
| | | | ensure that a block of code emits a message using the logging module.
* #8906: merge with 3.3.Ezio Melotti2013-03-291-12/+11
|\
| * #8906: document failureException, longMessage, and maxDiff in the class ↵Ezio Melotti2013-03-291-12/+11
| | | | | | | | docstring. Patch by Boris Feld.
* | #17329: merge with 3.3.Ezio Melotti2013-03-271-1/+1
|\ \ | |/
| * #17329: merge with 3.2.Ezio Melotti2013-03-271-1/+1
| |\
| | * #17329: document unittest.SkipTest. Initial patch by Zachary Ware.Ezio Melotti2013-03-271-1/+1
| | |
* | | Issue #16997: unittest.TestCase now provides a subTest() context manager to ↵Antoine Pitrou2013-03-201-86/+166
|/ / | | | | | | procedurally generate, in an easy way, small test instances.
* | Issue #16714: use 'raise' exceptions, don't 'throw'.Andrew Svetlov2012-12-181-2/+2
|\ \ | |/ | | | | Patch by Serhiy Storchaka.
| * Issue #16714: use 'raise' exceptions, don't 'throw'.Andrew Svetlov2012-12-181-2/+2
| | | | | | | | Patch by Serhiy Storchaka.
* | #16433: merge with 3.2.Ezio Melotti2012-11-081-1/+1
|\ \ | |/
| * #16433: fix docstring of assertNotEqual.Ezio Melotti2012-11-081-1/+1
| |
* | compare singletons by identity not equality (closes #16712)Benjamin Peterson2012-10-091-1/+1
| | | | | | | | Patch from Serhiy Storchaka.
* | Issue #14664: It is now possible to use @unittest.skip{If,Unless} on a test ↵Antoine Pitrou2012-04-251-1/+1
|\ \ | |/ | | | | class that doesn't inherit from TestCase (i.e. a mixin).
| * Issue #14664: It is now possible to use @unittest.skip{If,Unless} on a test ↵Antoine Pitrou2012-04-251-1/+1
| | | | | | | | class that doesn't inherit from TestCase (i.e. a mixin).
* | Drop unused import in unittest package.Florent Xicluna2011-11-041-2/+1
| |
* | #13012: use splitlines(keepends=True/False) instead of splitlines(0/1).Ezio Melotti2011-09-281-2/+2
| |
* | merge 3.2 (#12544)Benjamin Peterson2011-07-131-22/+3
|\ \ | |/
| * this can be done without a custom dict (also fixes #12544)Benjamin Peterson2011-07-131-22/+3
| |