| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
Now addClassCleanup() uses separate lists for different TestCase subclasses,
and doClassCleanups() only cleans up the particular class.
|
| |
|
|
|
|
|
|
| |
(GH-92556)
This reverts commit b50322d20337ca468f2070eedb051a16ee1eba94.
|
|
|
|
|
|
| |
Add methods enterContext() and enterClassContext() in TestCase.
Add method enterAsyncContext() in IsolatedAsyncioTestCase.
Add function enterModuleContext().
|
|
|
| |
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
|
|
|
|
|
|
|
|
|
|
| |
Revert "bpo-45162: Remove many old deprecated unittest features (GH-28268)"
This reverts commit b0a6ede3d0bd6fa4ffe413ab4dfc1059201df25b.
We're deferring this change until 3.12 while upstream projects that use
the legacy assertion method names are fixed. See the issue for links
to the discussion. Many upstream projects now have issues and PRs
filed.
|
|
|
|
|
|
| |
It runs now asynchronous methods and callbacks.
If it fails, doCleanups() can be called for cleaning up.
|
|
|
|
|
|
|
| |
TestResult methods addFailure(), addError(), addSkip() and
addSubTest() are now called immediately after raising an exception
in test or finishing a subtest. Previously they were called only
after finishing the test clean up.
|
|
|
|
|
|
|
|
| |
unittest.TestCase.debug() raises now a SkipTest if the class or
the test method are decorated with the skipping decorator.
Previously it only raised a SkipTest if the test method was decorated
with other decorator in addition to the skipping decorator, or
if SkipTest was explicitly raised in the test or setup methods.
|
|
|
|
|
|
|
| |
* "fail*" and "assert*" aliases of TestCase methods.
* Broken from start TestCase method assertDictContainsSubset().
* Ignored TestLoader.loadTestsFromModule() parameter use_load_tests.
* Old alias _TextTestResult of TextTestResult.
|
|
|
|
|
|
| |
Previously it returned None if the test class or method was
decorated with a skipping decorator.
Co-authored-by: Iman Tabrizian <iman.tabrizian@gmail.com>
|
|
|
|
| |
Also fix the traceback of warnings.
|
|
|
|
|
|
|
|
| |
objects (GH-27831)
Method stopTestRun() is now always called in pair with method startTestRun()
for TestResult objects implicitly created in TestCase.run().
Previously it was not called for test methods and classes decorated with
a skipping decorator.
|
| |
|
|
|
| |
Co-authored-by: Rémi Lapeyre <remi.lapeyre@henki.fr>
|
|
|
|
|
|
|
| |
unittest.TestCase.assertWarns no longer raises a RuntimeException
when accessing a module's ``__warningregistry__`` causes importation of a new
module, or when a new module is imported in another thread.
Patch by Kernc.
|
|
|
|
|
| |
Import logging lazily in assertLogs() in unittest.
Move TestHandler from test.support to logging_helper.
|
|
|
|
|
|
|
|
|
|
| |
- concurrent.futures
- ctypes
- http.cookies
- multiprocessing
- queue
- tempfile
- unittest.case
- urllib.parse
|
|
|
|
| |
TestCase.shortDescription (GH-18175)
|
|
|
|
|
|
|
| |
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
* Change default reason to empty string
* Fix rst formatting of NEWS entry
|
|
|
| |
Turn deprecation warnings added in 3.8 into TypeError.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|
|
|
| |
(GH-8623)
|
|
|
|
| |
The word "difference" from missing the sentence.
This clarifies that it compares the difference between the two objects.
|
| |
|
|
|
|
| |
order of keyword arguments of TestCase.subTest().
|
|
|
|
|
|
|
|
|
|
|
|
| |
* #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
|
|
|
|
| |
bpo-23890: unittest.TestCase.assertRaises() now manually breaks a
reference cycle to not keep objects alive longer than expected.
|
| |
|
|
|
|
| |
Based on patch by Ville Skyttä.
|
|
|
|
|
| |
differing items (like bytes in the -b mode). This affects assertListEqual()
and assertTupleEqual().
|
|\
| |
| |
| | |
Patch from Berker Peksag.
|
| |
| |
| |
| | |
Patch from Berker Peksag.
|
| | |
|
| |
| |
| |
| | |
Patch from Ilia Kurenkov.
|
| |
| |
| |
| |
| | |
assertWarnsRegex() assertments now check the type of the first argument
to prevent possible user error. Based on patch by Daniel Wagner-Hall.
|
|/
|
|
|
| |
assertWarnsRegex() checks now emits a deprecation warning when callable is
None or keyword arguments except msg is passed in the context manager mode.
|
| |
|
|
|
|
|
|
| |
assertWarnsRegex() checks are not longer successful if the callable is None.
Added tests for assertRaises().
|
|
|
|
| |
returned NotImplemented. Removed incorrect implementations of __ne__().
|
|
|
|
| |
in the exception's traceback.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
reference cycles between frames and the _Outcome instance.
|