diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-01-22 17:02:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-22 17:02:16 (GMT) |
commit | 5b12f7d2bd1f992c7140518806471739b215d498 (patch) | |
tree | 49f2cd2e6137a5fc7723666c6dc00a836319a43d /Lib | |
parent | 350b4c7c0cfbc221597a66eeb657e481335ffe0b (diff) | |
download | cpython-5b12f7d2bd1f992c7140518806471739b215d498.zip cpython-5b12f7d2bd1f992c7140518806471739b215d498.tar.gz cpython-5b12f7d2bd1f992c7140518806471739b215d498.tar.bz2 |
[3.11] gh-114275: Skip doctests that use `asyncio` in `test_pdb` for WASI builds (GH-114309) (#114438)
gh-114275: Skip doctests that use `asyncio` in `test_pdb` for WASI builds (GH-114309)
(cherry picked from commit efb81a60f5ce7e192095230a0f7ff9684d6f835a)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_pdb.py | 410 |
1 files changed, 208 insertions, 202 deletions
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index 30ad852..eed0273 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -19,6 +19,9 @@ from test.support.import_helper import import_module from test.support.pty_helper import run_pty, FakeInput from unittest.mock import patch +# gh-114275: WASI fails to run asyncio tests, similar skip than test_asyncio. +SKIP_ASYNCIO_TESTS = (not support.has_socket_support) + class PdbTestInput(object): """Context manager that makes testing Pdb in doctests easier.""" @@ -1071,122 +1074,123 @@ def test_pdb_next_command_for_generator(): finished """ -def test_pdb_next_command_for_coroutine(): - """Testing skip unwindng stack on yield for coroutines for "next" command - - >>> import asyncio - - >>> async def test_coro(): - ... await asyncio.sleep(0) - ... await asyncio.sleep(0) - ... await asyncio.sleep(0) - - >>> async def test_main(): - ... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace() - ... await test_coro() - - >>> def test_function(): - ... loop = asyncio.new_event_loop() - ... loop.run_until_complete(test_main()) - ... loop.close() - ... asyncio.set_event_loop_policy(None) - ... print("finished") - - >>> with PdbTestInput(['step', - ... 'step', - ... 'next', - ... 'next', - ... 'next', - ... 'step', - ... 'continue']): - ... test_function() - > <doctest test.test_pdb.test_pdb_next_command_for_coroutine[2]>(3)test_main() - -> await test_coro() - (Pdb) step - --Call-- - > <doctest test.test_pdb.test_pdb_next_command_for_coroutine[1]>(1)test_coro() - -> async def test_coro(): - (Pdb) step - > <doctest test.test_pdb.test_pdb_next_command_for_coroutine[1]>(2)test_coro() - -> await asyncio.sleep(0) - (Pdb) next - > <doctest test.test_pdb.test_pdb_next_command_for_coroutine[1]>(3)test_coro() - -> await asyncio.sleep(0) - (Pdb) next - > <doctest test.test_pdb.test_pdb_next_command_for_coroutine[1]>(4)test_coro() - -> await asyncio.sleep(0) - (Pdb) next - Internal StopIteration - > <doctest test.test_pdb.test_pdb_next_command_for_coroutine[2]>(3)test_main() - -> await test_coro() - (Pdb) step - --Return-- - > <doctest test.test_pdb.test_pdb_next_command_for_coroutine[2]>(3)test_main()->None - -> await test_coro() - (Pdb) continue - finished - """ - -def test_pdb_next_command_for_asyncgen(): - """Testing skip unwindng stack on yield for coroutines for "next" command - - >>> import asyncio - - >>> async def agen(): - ... yield 1 - ... await asyncio.sleep(0) - ... yield 2 - - >>> async def test_coro(): - ... async for x in agen(): - ... print(x) - - >>> async def test_main(): - ... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace() - ... await test_coro() - - >>> def test_function(): - ... loop = asyncio.new_event_loop() - ... loop.run_until_complete(test_main()) - ... loop.close() - ... asyncio.set_event_loop_policy(None) - ... print("finished") +if not SKIP_ASYNCIO_TESTS: + def test_pdb_next_command_for_coroutine(): + """Testing skip unwindng stack on yield for coroutines for "next" command + + >>> import asyncio + + >>> async def test_coro(): + ... await asyncio.sleep(0) + ... await asyncio.sleep(0) + ... await asyncio.sleep(0) + + >>> async def test_main(): + ... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace() + ... await test_coro() + + >>> def test_function(): + ... loop = asyncio.new_event_loop() + ... loop.run_until_complete(test_main()) + ... loop.close() + ... asyncio.set_event_loop_policy(None) + ... print("finished") + + >>> with PdbTestInput(['step', + ... 'step', + ... 'next', + ... 'next', + ... 'next', + ... 'step', + ... 'continue']): + ... test_function() + > <doctest test.test_pdb.test_pdb_next_command_for_coroutine[2]>(3)test_main() + -> await test_coro() + (Pdb) step + --Call-- + > <doctest test.test_pdb.test_pdb_next_command_for_coroutine[1]>(1)test_coro() + -> async def test_coro(): + (Pdb) step + > <doctest test.test_pdb.test_pdb_next_command_for_coroutine[1]>(2)test_coro() + -> await asyncio.sleep(0) + (Pdb) next + > <doctest test.test_pdb.test_pdb_next_command_for_coroutine[1]>(3)test_coro() + -> await asyncio.sleep(0) + (Pdb) next + > <doctest test.test_pdb.test_pdb_next_command_for_coroutine[1]>(4)test_coro() + -> await asyncio.sleep(0) + (Pdb) next + Internal StopIteration + > <doctest test.test_pdb.test_pdb_next_command_for_coroutine[2]>(3)test_main() + -> await test_coro() + (Pdb) step + --Return-- + > <doctest test.test_pdb.test_pdb_next_command_for_coroutine[2]>(3)test_main()->None + -> await test_coro() + (Pdb) continue + finished + """ - >>> with PdbTestInput(['step', - ... 'step', - ... 'next', - ... 'next', - ... 'step', - ... 'next', - ... 'continue']): - ... test_function() - > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[3]>(3)test_main() - -> await test_coro() - (Pdb) step - --Call-- - > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[2]>(1)test_coro() - -> async def test_coro(): - (Pdb) step - > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[2]>(2)test_coro() - -> async for x in agen(): - (Pdb) next - > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[2]>(3)test_coro() - -> print(x) - (Pdb) next - 1 - > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[2]>(2)test_coro() - -> async for x in agen(): - (Pdb) step - --Call-- - > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[1]>(2)agen() - -> yield 1 - (Pdb) next - > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[1]>(3)agen() - -> await asyncio.sleep(0) - (Pdb) continue - 2 - finished - """ + def test_pdb_next_command_for_asyncgen(): + """Testing skip unwindng stack on yield for coroutines for "next" command + + >>> import asyncio + + >>> async def agen(): + ... yield 1 + ... await asyncio.sleep(0) + ... yield 2 + + >>> async def test_coro(): + ... async for x in agen(): + ... print(x) + + >>> async def test_main(): + ... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace() + ... await test_coro() + + >>> def test_function(): + ... loop = asyncio.new_event_loop() + ... loop.run_until_complete(test_main()) + ... loop.close() + ... asyncio.set_event_loop_policy(None) + ... print("finished") + + >>> with PdbTestInput(['step', + ... 'step', + ... 'next', + ... 'next', + ... 'step', + ... 'next', + ... 'continue']): + ... test_function() + > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[3]>(3)test_main() + -> await test_coro() + (Pdb) step + --Call-- + > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[2]>(1)test_coro() + -> async def test_coro(): + (Pdb) step + > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[2]>(2)test_coro() + -> async for x in agen(): + (Pdb) next + > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[2]>(3)test_coro() + -> print(x) + (Pdb) next + 1 + > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[2]>(2)test_coro() + -> async for x in agen(): + (Pdb) step + --Call-- + > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[1]>(2)agen() + -> yield 1 + (Pdb) next + > <doctest test.test_pdb.test_pdb_next_command_for_asyncgen[1]>(3)agen() + -> await asyncio.sleep(0) + (Pdb) continue + 2 + finished + """ def test_pdb_return_command_for_generator(): """Testing no unwindng stack on yield for generators @@ -1243,47 +1247,48 @@ def test_pdb_return_command_for_generator(): finished """ -def test_pdb_return_command_for_coroutine(): - """Testing no unwindng stack on yield for coroutines for "return" command - - >>> import asyncio - - >>> async def test_coro(): - ... await asyncio.sleep(0) - ... await asyncio.sleep(0) - ... await asyncio.sleep(0) - - >>> async def test_main(): - ... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace() - ... await test_coro() - - >>> def test_function(): - ... loop = asyncio.new_event_loop() - ... loop.run_until_complete(test_main()) - ... loop.close() - ... asyncio.set_event_loop_policy(None) - ... print("finished") - - >>> with PdbTestInput(['step', - ... 'step', - ... 'next', - ... 'continue']): - ... test_function() - > <doctest test.test_pdb.test_pdb_return_command_for_coroutine[2]>(3)test_main() - -> await test_coro() - (Pdb) step - --Call-- - > <doctest test.test_pdb.test_pdb_return_command_for_coroutine[1]>(1)test_coro() - -> async def test_coro(): - (Pdb) step - > <doctest test.test_pdb.test_pdb_return_command_for_coroutine[1]>(2)test_coro() - -> await asyncio.sleep(0) - (Pdb) next - > <doctest test.test_pdb.test_pdb_return_command_for_coroutine[1]>(3)test_coro() - -> await asyncio.sleep(0) - (Pdb) continue - finished - """ +if not SKIP_ASYNCIO_TESTS: + def test_pdb_return_command_for_coroutine(): + """Testing no unwindng stack on yield for coroutines for "return" command + + >>> import asyncio + + >>> async def test_coro(): + ... await asyncio.sleep(0) + ... await asyncio.sleep(0) + ... await asyncio.sleep(0) + + >>> async def test_main(): + ... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace() + ... await test_coro() + + >>> def test_function(): + ... loop = asyncio.new_event_loop() + ... loop.run_until_complete(test_main()) + ... loop.close() + ... asyncio.set_event_loop_policy(None) + ... print("finished") + + >>> with PdbTestInput(['step', + ... 'step', + ... 'next', + ... 'continue']): + ... test_function() + > <doctest test.test_pdb.test_pdb_return_command_for_coroutine[2]>(3)test_main() + -> await test_coro() + (Pdb) step + --Call-- + > <doctest test.test_pdb.test_pdb_return_command_for_coroutine[1]>(1)test_coro() + -> async def test_coro(): + (Pdb) step + > <doctest test.test_pdb.test_pdb_return_command_for_coroutine[1]>(2)test_coro() + -> await asyncio.sleep(0) + (Pdb) next + > <doctest test.test_pdb.test_pdb_return_command_for_coroutine[1]>(3)test_coro() + -> await asyncio.sleep(0) + (Pdb) continue + finished + """ def test_pdb_until_command_for_generator(): """Testing no unwindng stack on yield for generators @@ -1329,52 +1334,53 @@ def test_pdb_until_command_for_generator(): finished """ -def test_pdb_until_command_for_coroutine(): - """Testing no unwindng stack for coroutines - for "until" command if target breakpoint is not reached - - >>> import asyncio - - >>> async def test_coro(): - ... print(0) - ... await asyncio.sleep(0) - ... print(1) - ... await asyncio.sleep(0) - ... print(2) - ... await asyncio.sleep(0) - ... print(3) - - >>> async def test_main(): - ... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace() - ... await test_coro() - - >>> def test_function(): - ... loop = asyncio.new_event_loop() - ... loop.run_until_complete(test_main()) - ... loop.close() - ... asyncio.set_event_loop_policy(None) - ... print("finished") - - >>> with PdbTestInput(['step', - ... 'until 8', - ... 'continue']): - ... test_function() - > <doctest test.test_pdb.test_pdb_until_command_for_coroutine[2]>(3)test_main() - -> await test_coro() - (Pdb) step - --Call-- - > <doctest test.test_pdb.test_pdb_until_command_for_coroutine[1]>(1)test_coro() - -> async def test_coro(): - (Pdb) until 8 - 0 - 1 - 2 - > <doctest test.test_pdb.test_pdb_until_command_for_coroutine[1]>(8)test_coro() - -> print(3) - (Pdb) continue - 3 - finished - """ +if not SKIP_ASYNCIO_TESTS: + def test_pdb_until_command_for_coroutine(): + """Testing no unwindng stack for coroutines + for "until" command if target breakpoint is not reached + + >>> import asyncio + + >>> async def test_coro(): + ... print(0) + ... await asyncio.sleep(0) + ... print(1) + ... await asyncio.sleep(0) + ... print(2) + ... await asyncio.sleep(0) + ... print(3) + + >>> async def test_main(): + ... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace() + ... await test_coro() + + >>> def test_function(): + ... loop = asyncio.new_event_loop() + ... loop.run_until_complete(test_main()) + ... loop.close() + ... asyncio.set_event_loop_policy(None) + ... print("finished") + + >>> with PdbTestInput(['step', + ... 'until 8', + ... 'continue']): + ... test_function() + > <doctest test.test_pdb.test_pdb_until_command_for_coroutine[2]>(3)test_main() + -> await test_coro() + (Pdb) step + --Call-- + > <doctest test.test_pdb.test_pdb_until_command_for_coroutine[1]>(1)test_coro() + -> async def test_coro(): + (Pdb) until 8 + 0 + 1 + 2 + > <doctest test.test_pdb.test_pdb_until_command_for_coroutine[1]>(8)test_coro() + -> print(3) + (Pdb) continue + 3 + finished + """ def test_pdb_next_command_in_generator_for_loop(): """The next command on returning from a generator controlled by a for loop. |