PATH:
opt
/
bitninja-python-dojo
/
embedded
/
lib
/
python3.9
/
test
/
test_asyncio
import asyncio import decimal import unittest def tearDownModule(): asyncio.set_event_loop_policy(None) @unittest.skipUnless(decimal.HAVE_CONTEXTVAR, "decimal is built with a thread-local context") class DecimalContextTest(unittest.TestCase): def test_asyncio_task_decimal_context(self): async def fractions(t, precision, x, y): with decimal.localcontext() as ctx: ctx.prec = precision a = decimal.Decimal(x) / decimal.Decimal(y) await asyncio.sleep(t) b = decimal.Decimal(x) / decimal.Decimal(y ** 2) return a, b async def main(): r1, r2 = await asyncio.gather( fractions(0.1, 3, 1, 3), fractions(0.2, 6, 1, 3)) return r1, r2 r1, r2 = asyncio.run(main()) self.assertEqual(str(r1[0]), '0.333') self.assertEqual(str(r1[1]), '0.111') self.assertEqual(str(r2[0]), '0.333333') self.assertEqual(str(r2[1]), '0.111111')
[-] test_sslproto.py
[edit]
[-] test_futures2.py
[edit]
[-] test_streams.py
[edit]
[-] test_threads.py
[edit]
[-] test_windows_utils.py
[edit]
[-] test_buffered_proto.py
[edit]
[-] test_sock_lowlevel.py
[edit]
[-] test_tasks.py
[edit]
[-] test_unix_events.py
[edit]
[-] test_server.py
[edit]
[-] test_pep492.py
[edit]
[+]
..
[-] test_futures.py
[edit]
[-] test_context.py
[edit]
[-] test_sendfile.py
[edit]
[-] test_transports.py
[edit]
[-] __main__.py
[edit]
[-] echo2.py
[edit]
[-] test_locks.py
[edit]
[-] test_queues.py
[edit]
[+]
__pycache__
[-] test_base_events.py
[edit]
[-] utils.py
[edit]
[-] echo3.py
[edit]
[-] test_events.py
[edit]
[-] test_proactor_events.py
[edit]
[-] test_selector_events.py
[edit]
[-] functional.py
[edit]
[-] __init__.py
[edit]
[-] test_windows_events.py
[edit]
[-] test_asyncio_waitfor.py
[edit]
[-] test_runners.py
[edit]
[-] echo.py
[edit]
[-] test_protocols.py
[edit]
[-] test_subprocess.py
[edit]