cpython/Lib
Andrew Svetlov 4dd3e3f9bb bpo-32972: Async test case (GH-13386)
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
2019-05-29 02:33:59 -07:00
..
asyncio bpo-35246: fix support for path-like args in asyncio subprocess (GH-13628) 2019-05-28 23:50:59 -07:00
collections bpo-25652: Fix __rmod__ of UserString (GH-13326) 2019-05-21 13:27:36 -07:00
concurrent bpo-35279: reduce default max_workers of ThreadPoolExecutor (GH-13618) 2019-05-28 21:02:52 +09:00
ctypes bpo-36946: Fix possible signed integer overflow when handling slices. (GH-13375) 2019-05-17 10:13:03 +03:00
curses bpo-36542: Allow to overwrite the signature for Python functions. (GH-12705) 2019-05-06 22:40:27 +03:00
dbm bpo-36232: Improve error message on dbm.open() when the db doesn't exist (GH-12060) 2019-04-29 16:23:28 -07:00
distutils bpo-21536: On Cygwin, C extensions must be linked with libpython (GH-13549) 2019-05-24 17:33:47 +02:00
email bpo-27737: Allow whitespace only headers encoding (#13478) 2019-05-22 21:13:16 -04:00
encodings bpo-36778: cp65001 encoding becomes an alias to utf_8 (GH-13230) 2019-05-10 03:19:54 +02:00
ensurepip bpo-35807: Upgrade ensurepip bundled pip and setuptools (GH-12189) 2019-03-06 06:42:21 -05:00
html bpo-30629: Remove second call of str.lower() in html.parser.parse_endtag. (#2099) 2017-06-16 21:15:25 -04:00
http bpo-36793: Remove unneeded __str__ definitions. (GH-13081) 2019-05-06 22:29:40 +03:00
idlelib bpo-37039: IDLE - zoomheight fixes (GH-13576) 2019-05-27 19:16:46 -04:00
importlib bpo-34632: Add importlib.metadata (GH-12547) 2019-05-24 16:59:01 -07:00
json json.tool: use stdin and stdout in default cmdlne arguments (GH-11992) 2019-05-14 18:52:42 +02:00
lib2to3 bpo-23896: Add a grammar where exec isn't a stmt (#13272) 2019-05-20 13:27:10 -07:00
logging bpo-36015: Handle StreamHandler representaton of stream with an integer name (GH-11908) 2019-05-07 22:36:39 +01:00
msilib bpo-34251: Restore msilib.Win64 to preserve compatibility (GH-8510) 2018-07-28 16:02:56 -05:00
multiprocessing bpo-33725: multiprocessing uses spawn by default on macOS (GH-13603) 2019-05-28 16:02:50 +02:00
pydoc_data Python 3.8.0a4 2019-05-06 20:30:25 +02:00
site-packages
sqlite3 bpo-35504: Fix segfaults and SystemErrors when deleting certain attrs. (GH-11175) 2018-12-17 16:52:45 +02:00
test bpo-32972: Async test case (GH-13386) 2019-05-29 02:33:59 -07:00
tkinter bpo-25451: Add transparency methods to tkinter.PhotoImage. (GH-10406) 2019-04-05 13:17:13 +03:00
turtledemo turtledemo/penrose.py: remove unused clock() calls (GH-10033) 2018-10-25 00:43:39 +02:00
unittest bpo-32972: Async test case (GH-13386) 2019-05-29 02:33:59 -07:00
urllib bpo-35397: Remove deprecation and document urllib.parse.unwrap (GH-11481) 2019-05-27 09:43:45 -04:00
venv bpo-34144: Fix of venv acvtivate.bat for win 10 (GH-8321) 2019-04-10 10:19:16 -07:00
wsgiref bpo-8138: Initialize wsgiref's SimpleServer as single-threaded (GH-12977) 2019-05-24 20:24:42 +03:00
xml bpo-36831: Do not apply default namespace to unprefixed attributes in ElementPath. (#13201) 2019-05-09 07:22:47 +02:00
xmlrpc bpo-36793: Remove unneeded __str__ definitions. (GH-13081) 2019-05-06 22:29:40 +03:00
__future__.py bpo-35526: make __future__.barry_as_FLUFL mandatory for Python 4.0 (#11218) 2018-12-19 08:19:39 -08:00
__phello__.foo.py
_bootlocale.py bpo-29240: PEP 540: Add a new UTF-8 Mode (#855) 2017-12-13 12:29:09 +01:00
_collections_abc.py bpo-34427: Fix infinite loop when calling MutableSequence.extend() on self (GH-8813) 2018-08-30 09:56:14 -07:00
_compat_pickle.py bpo-35224: PEP 572 Implementation (#10497) 2019-01-24 16:49:56 -07:00
_compression.py
_dummy_thread.py Revert "bpo-36084: Add native thread ID to threading.Thread objects (GH-11993)" (GH-13458) 2019-05-21 12:44:57 +02:00
_markupbase.py
_osx_support.py bpo-35257: Avoid leaking LTO linker flags into distutils (GH-10900) 2018-12-19 18:19:01 +01:00
_py_abc.py bpo-33018: Improve issubclass() error checking and message. (GH-5944) 2018-03-22 11:26:06 +00:00
_pydecimal.py bpo-36793: Remove unneeded __str__ definitions. (GH-13081) 2019-05-06 22:29:40 +03:00
_pyio.py bpo-37054, _pyio: Fix BytesIO and TextIOWrapper __del__() (GH-13601) 2019-05-28 01:44:21 +02:00
_sitebuiltins.py
_strptime.py bpo-33541: Remove unused __pad function (GH-4377) 2018-05-20 13:42:30 -04:00
_threading_local.py Delete a broken threading.local example (#5870) 2018-02-25 10:03:40 -05:00
_weakrefset.py bpo-36949: Implement __repr__ on WeakSet (GH-13415) 2019-05-20 10:01:07 -07:00
abc.py bpo-35609: Remove examples for deprecated decorators in the abc module. (GH-11355) 2018-12-31 09:56:21 +02:00
aifc.py bpo-32056: Improve exceptions in aifc, wave and sunau. (GH-5951) 2018-03-18 09:55:53 +02:00
antigravity.py Change the xkcd link in comment over https. (GH-5452) 2018-09-13 22:45:00 -07:00
argparse.py bpo-23378: Add an extend action to argparse (GH-13305) 2019-05-21 10:47:42 -07:00
ast.py bpo-35975: Support parsing earlier minor versions of Python 3 (GH-12086) 2019-03-07 12:38:08 -08:00
asynchat.py
asyncore.py bpo-36793: Remove unneeded __str__ definitions. (GH-13081) 2019-05-06 22:29:40 +03:00
base64.py bpo-34164: Fix handling of incorrect padding in base64.b32decode(). (GH-8351) 2018-07-24 12:52:51 +03:00
bdb.py bpo-36542: Allow to overwrite the signature for Python functions. (GH-12705) 2019-05-06 22:40:27 +03:00
binhex.py
bisect.py remove duplicate code in biscet (GH-1270) 2019-04-08 17:01:09 +09:00
bz2.py bpo-35128: Fix spacing issues in warning.warn() messages. (GH-10268) 2018-11-01 12:33:35 +02:00
cProfile.py bpo-36542: Allow to overwrite the signature for Python functions. (GH-12705) 2019-05-06 22:40:27 +03:00
calendar.py
cgi.py bpo-35028: cgi: Fix max_num_fields off by one error (GH-9973) 2018-10-23 01:14:35 -07:00
cgitb.py bpo-33311: Do not display parameters displayed in parentheses for module call. (GH-6677) 2018-05-09 12:39:32 +03:00
chunk.py
cmd.py
code.py
codecs.py bpo-33482: fix codecs.StreamRecoder.writelines (GH-6779) 2019-05-22 08:18:26 -07:00
codeop.py
colorsys.py
compileall.py bpo-36786: Run compileall in parallel during "make install" (GH-13078) 2019-05-15 23:45:18 +02:00
configparser.py fix typo in configparser doc (GH-12154) 2019-03-03 18:23:19 -08:00
contextlib.py bpo-36542: Allow to overwrite the signature for Python functions. (GH-12705) 2019-05-06 22:40:27 +03:00
contextvars.py bpo-32436: Implement PEP 567 (#5027) 2018-01-22 19:11:18 -05:00
copy.py bpo-11572: Make minor improvements to copy module (GH-8208) 2018-07-09 23:14:54 +03:00
copyreg.py bpo-33138: Change standard error message for non-pickleable and non-copyable types. (GH-6239) 2018-10-31 02:28:07 +02:00
crypt.py bpo-31702: Allow to specify rounds for SHA-2 hashing in crypt.mksalt(). (#4110) 2017-11-16 13:22:51 +02:00
csv.py bpo-27497: Add return value to csv.DictWriter.writeheader (GH-12306) 2019-05-10 03:50:11 +02:00
dataclasses.py bpo-35960: Fix dataclasses.field throwing away empty metadata. (GH-11815) 2019-02-12 06:50:49 -05:00
datetime.py bpo-36004: Add date.fromisocalendar (GH-11888) 2019-04-29 15:22:03 +02:00
decimal.py
difflib.py Revert "bpo-35603: Escape table header of make_table output that can cause potential XSS. (GH-11341)" (GH-11356) 2019-01-02 14:49:25 +02:00
dis.py bpo-36540: PEP 570 -- Implementation (GH-12701) 2019-04-29 13:36:57 +01:00
doctest.py bpo-36793: Remove unneeded __str__ definitions. (GH-13081) 2019-05-06 22:29:40 +03:00
dummy_threading.py
enum.py bpo-35899: Fix Enum handling of empty and weird strings (GH-11891) 2019-03-03 14:09:11 -08:00
filecmp.py
fileinput.py bpo-36952: Remove the bufsize parameter in fileinput.input(). (GH-13400) 2019-05-20 23:44:11 +03:00
fnmatch.py bpo-32775: Fix regular expression warnings in fnmatch. (#5583) 2018-02-09 13:30:19 +02:00
formatter.py
fractions.py bpo-36625: Remove obsolete comments from docstrings in fractions module (GH-12822) 2019-04-15 13:37:04 +01:00
ftplib.py bpo-35934: Add socket.create_server() utility function (GH-11784) 2019-04-09 00:34:02 +02:00
functools.py bpo-36772 Allow lru_cache to be used as decorator without making a function call (GH-13048) 2019-05-26 11:27:35 -07:00
genericpath.py bpo-33721: Make some os.path functions and pathlib.Path methods be tolerant to invalid paths. (#7695) 2018-09-18 11:28:51 +03:00
getopt.py
getpass.py
gettext.py bpo-36239: Skip comments in gettext infos (GH-12255) 2019-05-09 16:22:15 +02:00
glob.py
gzip.py bpo-6584: Add a BadGzipFile exception to the gzip module. (GH-13022) 2019-05-13 10:50:52 +03:00
hashlib.py bpo-33729: Fix issues with arguments parsing in hashlib. (GH-8346) 2018-07-31 09:50:16 +03:00
heapq.py bpo-34149: Behavior of the min/max with key=None (GH-8328) 2018-07-23 20:58:21 -07:00
hmac.py bpo-33604: Remove deprecated HMAC default value marked for removal in 3.8 (GH-7063) 2018-09-10 11:10:01 -07:00
imaplib.py bpo-36348: IMAP4.logout() doesn't ignore exc (GH-12411) 2019-04-15 18:23:20 +02:00
imghdr.py
imp.py closes bpo-34056: Always return bytes from _HackedGetData.get_data(). (GH-8130) 2018-07-06 20:41:06 -07:00
inspect.py bpo-36751: Undeprecate getfullargspec (GH-13245) 2019-05-16 21:08:15 +01:00
io.py bpo-36842: Implement PEP 578 (GH-12613) 2019-05-23 08:45:22 -07:00
ipaddress.py bpo-36845: validate integer network prefix when constructing IP networks (GH-13298) 2019-05-14 19:32:59 +09:00
keyword.py bpo-36143: Regenerate Lib/keyword.py from the Grammar and Tokens file using pgen (GH-12456) 2019-03-25 22:01:12 +00:00
linecache.py
locale.py Remove mojibake in the locale aliases mapping. (GH-6716) 2018-05-06 10:52:38 +03:00
lzma.py
mailbox.py bpo-31522: mailbox.get_string: pass `from_` parameter to `get_bytes` (#9857) 2018-10-18 20:21:47 -04:00
mailcap.py
mimetypes.py bpo-34926: Make mimetypes.guess_type accept os.PathLike objects (GH-9777) 2018-10-10 16:46:44 +02:00
modulefinder.py bpo-37032: Add CodeType.replace() method (GH-13542) 2019-05-24 23:57:23 +02:00
netrc.py bpo-28334: netrc() now uses expanduser() to find .netrc file (GH-4537) 2017-11-25 13:37:22 +03:00
nntplib.py
ntpath.py bpo-30427: eliminate redundant type checks in os.path.normcase() (GH-1712) 2019-03-28 14:47:18 -07:00
nturl2path.py
numbers.py
opcode.py bpo-33041: Rework compiling an "async for" loop. (#6142) 2018-03-23 14:34:35 +02:00
operator.py
optparse.py bpo-34605: Avoid master/slave terms (GH-9101) 2018-09-07 17:30:33 +02:00
os.py bpo-36085: Enable better DLL resolution on Windows (GH-12302) 2019-03-29 16:37:16 -07:00
pathlib.py bpo-36035: fix Path.rglob for broken links (GH-11988) 2019-05-21 19:44:40 +02:00
pdb.py bpo-36969: Make PDB args command display positional only arguments (GH-13459) 2019-05-24 21:44:31 +01:00
pickle.py bpo-36785: PEP 574 implementation (GH-7076) 2019-05-26 17:10:09 +02:00
pickletools.py bpo-36785: PEP 574 implementation (GH-7076) 2019-05-26 17:10:09 +02:00
pipes.py
pkgutil.py closes bpo-31650: PEP 552 (Deterministic pycs) implementation (#4575) 2017-12-09 10:26:52 -08:00
platform.py bpo-36766: Typos in docs and code comments (GH-13116) 2019-05-06 14:57:17 -04:00
plistlib.py bpo-26707: Enable plistlib to read UID keys. (GH-12153) 2019-05-15 23:14:38 +03:00
poplib.py bpo-35128: Fix spacing issues in warning.warn() messages. (GH-10268) 2018-11-01 12:33:35 +02:00
posixpath.py bpo-35755: Remove current directory from posixpath.defpath (GH-11586) 2019-04-17 17:05:30 +02:00
pprint.py bpo-30670: Add pp function to the pprint module (GH-11769) 2019-03-22 10:22:20 -07:00
profile.py bpo-36542: Allow to overwrite the signature for Python functions. (GH-12705) 2019-05-06 22:40:27 +03:00
pstats.py bpo-36766: Typos in docs and code comments (GH-13116) 2019-05-06 14:57:17 -04:00
pty.py
py_compile.py bpo-22640: Add silent mode to py_compile.compile() (GH-12976) 2019-05-28 19:29:04 +03:00
pyclbr.py bpo-36298: Raise ModuleNotFoundError in pyclbr when a module can't be found (GH-12358) 2019-03-22 15:16:50 -07:00
pydoc.py bpo-36045: builtins.help() now prefixes `async` for async functions (GH-12010) 2019-05-24 04:38:01 -07:00
queue.py bpo-14976: Reentrant simple queue (#3346) 2018-01-16 00:27:16 +01:00
quopri.py
random.py bpo-36559: random module: optimize sha512 import (GH-12742) 2019-04-10 13:18:02 -07:00
re.py bpo-34681: Rename class Pattern in sre_parse to State. (GH-9310) 2018-09-18 09:16:26 +03:00
reprlib.py
rlcompleter.py
runpy.py
sched.py
secrets.py
selectors.py
shelve.py Fix misleading docsting of shelve.open(). (GH-6427) 2018-04-09 17:16:01 +03:00
shlex.py bpo-22454: Add shlex.join() (the opposite of shlex.split()) (GH-7605) 2019-05-29 09:06:11 +01:00
shutil.py bpo-24538: Fix bug in shutil involving the copying of xattrs to read-only files. (PR-13212) 2019-05-10 11:22:06 +08:00
signal.py bpo-34282: Fix Enum._convert shadowing members named _convert (GH-8568) 2018-09-12 10:28:53 -07:00
site.py bpo-35872 and bpo-35873: Clears __PYVENV_LAUNCHER__ variable (GH-11745) 2019-02-03 23:19:38 -08:00
smtpd.py
smtplib.py bpo-35128: Fix spacing issues in warning.warn() messages. (GH-10268) 2018-11-01 12:33:35 +02:00
sndhdr.py
socket.py BPO-17561: set create_server backlog default to None (GH-12735) 2019-04-09 04:42:06 +02:00
socketserver.py Fix typo in socketserver docstring (GH-11252) 2018-12-21 14:22:09 -08:00
sre_compile.py Simplify flags checks in sre_compile.py. (GH-9718) 2018-10-05 20:53:45 +03:00
sre_constants.py bpo-36793: Remove unneeded __str__ definitions. (GH-13081) 2019-05-06 22:29:40 +03:00
sre_parse.py bpo-34681: Rename class Pattern in sre_parse to State. (GH-9310) 2018-09-18 09:16:26 +03:00
ssl.py Simplify SSLSocket / SSLObject doc string (GH-9972) 2019-05-17 13:08:14 +02:00
stat.py closes bpo-34353: Add sockets to stat.filemode fallback python implementation. (GH-8703) 2018-08-09 22:12:08 -07:00
statistics.py bpo-36018: Make "seed" into a keyword only argument (GH-12921) 2019-04-23 01:46:18 -07:00
string.py bpo-31672: Restore the former behavior when override flags in Template. (#5099) 2018-01-04 19:20:11 +02:00
stringprep.py
struct.py
subprocess.py bpo-31961: Fix support of path-like executables in subprocess. (GH-5914) 2019-05-28 22:49:35 +03:00
sunau.py bpo-32056: Improve exceptions in aifc, wave and sunau. (GH-5951) 2018-03-18 09:55:53 +02:00
symbol.py bpo-35766: Merge typed_ast back into CPython (GH-11645) 2019-01-31 12:40:27 +01:00
symtable.py bpo-34983: Expose symtable.Symbol.is_nonlocal() in the symtable module (GH-9872) 2018-10-20 01:46:00 +01:00
sysconfig.py bpo-35920: Windows 10 ARM32 platform support (GH-11774) 2019-04-25 18:36:45 +00:00
tabnanny.py
tarfile.py Add missing docstrings for TarInfo objects (#12555) 2019-03-27 13:16:34 -07:00
telnetlib.py
tempfile.py Clean up code which checked presence of os.{stat,lstat,chmod} (#11643) 2019-02-25 23:32:27 +01:00
textwrap.py
this.py
threading.py bpo-1230540: Add threading.excepthook() (GH-13515) 2019-05-28 00:39:52 +02:00
timeit.py bpo-28240: timeit: Update repeat() doc (GH-7419) 2018-06-06 17:55:18 +02:00
token.py bpo-35975: Support parsing earlier minor versions of Python 3 (GH-12086) 2019-03-07 12:38:08 -08:00
tokenize.py bpo-36766: Typos in docs and code comments (GH-13116) 2019-05-06 14:57:17 -04:00
trace.py bpo-36542: Allow to overwrite the signature for Python functions. (GH-12705) 2019-05-06 22:40:27 +03:00
traceback.py bpo-26502: Implement FrameSummary.__len__() (GH-8632) 2018-09-10 10:02:33 -07:00
tracemalloc.py bpo-32121: Add most_recent_first parameter to tracemalloc.Traceback.format (#4534) 2017-11-30 00:05:07 +01:00
tty.py
turtle.py bpo-36766: Typos in docs and code comments (GH-13116) 2019-05-06 14:57:17 -04:00
types.py bpo-37032: Add CodeType.replace() method (GH-13542) 2019-05-24 23:57:23 +02:00
typing.py bpo-37058: PEP 544: Add Protocol to typing module (GH-13585) 2019-05-28 08:40:15 +01:00
uu.py bpo-33687: Fix call to os.chmod() in uu.decode() (GH-7282) 2019-01-17 17:15:53 +03:00
uuid.py bpo-35701: Added __weakref__ slot to uuid.UUID (GH-11570) 2019-01-17 13:16:51 +01:00
warnings.py bpo-35178: Fix warnings._formatwarnmsg() (GH-12033) 2019-03-01 18:17:55 +01:00
wave.py bpo-32056: Improve exceptions in aifc, wave and sunau. (GH-5951) 2018-03-18 09:55:53 +02:00
weakref.py bpo-36542: Allow to overwrite the signature for Python functions. (GH-12705) 2019-05-06 22:40:27 +03:00
webbrowser.py bpo-35308: Fix regression where BROWSER env var is not respected. (GH-10693) 2018-11-26 23:29:45 +02:00
xdrlib.py
zipapp.py
zipfile.py bpo-22102: Fixes zip files with disks set to 0 (GH-5985) 2019-05-28 19:15:11 -04:00
zipimport.py bpo-36842: Implement PEP 578 (GH-12613) 2019-05-23 08:45:22 -07:00