✘✘ GRAYBYTE WORDPRESS FILE MANAGER ✘✘

​🇳​​🇦​​🇲​​🇪♯➤ beluga.o2switch.net ​🇻​♯➤ 4.18.0-553.123.2.lve.el8.x86_64 #1 SMP 🇾​♯➤ 2026

𝗛𝗢𝗠𝗘 𝗜𝗗 ♯➤ 185.154.139.77 ♯➤ 𝗔𝗗𝗠𝗜𝗡 𝗜𝗗 216.73.216.84
𝗢𝗣𝗧𝗜𝗢𝗡𝗦 ♯ CRL ♯➤ 𝗢𝗞 ┃ WGT ♯➤ 𝗢𝗞 ┃ SDO ♯➤ 𝗢𝗙𝗙 ┃ PKEX ♯➤ 𝗢𝗙𝗙
𝗗𝗘𝗔𝗖𝗧𝗜𝗩𝗔𝗧𝗘𝗗 ♯➤ 𝗔𝗟𝗟 𝗪𝗢𝗥𝗞𝗜𝗡𝗚....

𝗛𝗢𝗠𝗘
𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /opt/alt/python38/lib64/python3.8/test/test_asyncio//test_pep492.py
"""Tests support for new syntax introduced by PEP 492."""

import sys
import types
import unittest

from unittest import mock

import asyncio
from test.test_asyncio import utils as test_utils


def tearDownModule():
    asyncio.set_event_loop_policy(None)


# Test that asyncio.iscoroutine() uses collections.abc.Coroutine
class FakeCoro:
    def send(self, value):
        pass

    def throw(self, typ, val=None, tb=None):
        pass

    def close(self):
        pass

    def __await__(self):
        yield


class BaseTest(test_utils.TestCase):

    def setUp(self):
        super().setUp()
        self.loop = asyncio.BaseEventLoop()
        self.loop._process_events = mock.Mock()
        self.loop._selector = mock.Mock()
        self.loop._selector.select.return_value = ()
        self.set_event_loop(self.loop)


class LockTests(BaseTest):

    def test_context_manager_async_with(self):
        with self.assertWarns(DeprecationWarning):
            primitives = [
                asyncio.Lock(loop=self.loop),
                asyncio.Condition(loop=self.loop),
                asyncio.Semaphore(loop=self.loop),
                asyncio.BoundedSemaphore(loop=self.loop),
            ]

        async def test(lock):
            await asyncio.sleep(0.01)
            self.assertFalse(lock.locked())
            async with lock as _lock:
                self.assertIs(_lock, None)
                self.assertTrue(lock.locked())
                await asyncio.sleep(0.01)
                self.assertTrue(lock.locked())
            self.assertFalse(lock.locked())

        for primitive in primitives:
            self.loop.run_until_complete(test(primitive))
            self.assertFalse(primitive.locked())

    def test_context_manager_with_await(self):
        with self.assertWarns(DeprecationWarning):
            primitives = [
                asyncio.Lock(loop=self.loop),
                asyncio.Condition(loop=self.loop),
                asyncio.Semaphore(loop=self.loop),
                asyncio.BoundedSemaphore(loop=self.loop),
            ]

        async def test(lock):
            await asyncio.sleep(0.01)
            self.assertFalse(lock.locked())
            with self.assertWarns(DeprecationWarning):
                with await lock as _lock:
                    self.assertIs(_lock, None)
                    self.assertTrue(lock.locked())
                    await asyncio.sleep(0.01)
                    self.assertTrue(lock.locked())
                self.assertFalse(lock.locked())

        for primitive in primitives:
            self.loop.run_until_complete(test(primitive))
            self.assertFalse(primitive.locked())


class StreamReaderTests(BaseTest):

    def test_readline(self):
        DATA = b'line1\nline2\nline3'

        stream = asyncio.StreamReader(loop=self.loop)
        stream.feed_data(DATA)
        stream.feed_eof()

        async def reader():
            data = []
            async for line in stream:
                data.append(line)
            return data

        data = self.loop.run_until_complete(reader())
        self.assertEqual(data, [b'line1\n', b'line2\n', b'line3'])


class CoroutineTests(BaseTest):

    def test_iscoroutine(self):
        async def foo(): pass

        f = foo()
        try:
            self.assertTrue(asyncio.iscoroutine(f))
        finally:
            f.close() # silence warning

        self.assertTrue(asyncio.iscoroutine(FakeCoro()))

    def test_iscoroutinefunction(self):
        async def foo(): pass
        self.assertTrue(asyncio.iscoroutinefunction(foo))

    def test_function_returning_awaitable(self):
        class Awaitable:
            def __await__(self):
                return ('spam',)

        with self.assertWarns(DeprecationWarning):
            @asyncio.coroutine
            def func():
                return Awaitable()

        coro = func()
        self.assertEqual(coro.send(None), 'spam')
        coro.close()

    def test_async_def_coroutines(self):
        async def bar():
            return 'spam'
        async def foo():
            return await bar()

        # production mode
        data = self.loop.run_until_complete(foo())
        self.assertEqual(data, 'spam')

        # debug mode
        self.loop.set_debug(True)
        data = self.loop.run_until_complete(foo())
        self.assertEqual(data, 'spam')

    def test_debug_mode_manages_coroutine_origin_tracking(self):
        async def start():
            self.assertTrue(sys.get_coroutine_origin_tracking_depth() > 0)

        self.assertEqual(sys.get_coroutine_origin_tracking_depth(), 0)
        self.loop.set_debug(True)
        self.loop.run_until_complete(start())
        self.assertEqual(sys.get_coroutine_origin_tracking_depth(), 0)

    def test_types_coroutine(self):
        def gen():
            yield from ()
            return 'spam'

        @types.coroutine
        def func():
            return gen()

        async def coro():
            wrapper = func()
            self.assertIsInstance(wrapper, types._GeneratorWrapper)
            return await wrapper

        data = self.loop.run_until_complete(coro())
        self.assertEqual(data, 'spam')

    def test_task_print_stack(self):
        T = None

        async def foo():
            f = T.get_stack(limit=1)
            try:
                self.assertEqual(f[0].f_code.co_name, 'foo')
            finally:
                f = None

        async def runner():
            nonlocal T
            T = asyncio.ensure_future(foo(), loop=self.loop)
            await T

        self.loop.run_until_complete(runner())

    def test_double_await(self):
        async def afunc():
            await asyncio.sleep(0.1)

        async def runner():
            coro = afunc()
            t = self.loop.create_task(coro)
            try:
                await asyncio.sleep(0)
                await coro
            finally:
                t.cancel()

        self.loop.set_debug(True)
        with self.assertRaises(
                RuntimeError,
                msg='coroutine is being awaited already'):

            self.loop.run_until_complete(runner())


if __name__ == '__main__':
    unittest.main()


Current_dir [ 𝗡𝗢𝗧 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ] Document_root [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ]


[ Back ]
𝗡𝗔𝗠𝗘
𝗦𝗜𝗭𝗘
𝗟𝗔𝗦𝗧 𝗧𝗢𝗨𝗖𝗛
𝗨𝗦𝗘𝗥
𝗦𝗧𝗔𝗧𝗨𝗦
𝗙𝗨𝗡𝗖𝗧𝗜𝗢𝗡𝗦
..
--
25 Oct 2024 11.54 AM
root / linksafe
0755
__pycache__
--
25 Oct 2024 11.54 AM
root / linksafe
0755
__init__.py
0.238 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
__main__.py
0.057 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
echo.py
0.145 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
echo2.py
0.12 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
echo3.py
0.27 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
functional.py
7.466 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_asyncio_waitfor.py
1.453 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_base_events.py
78.138 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_buffered_proto.py
2.282 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_context.py
0.996 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_events.py
99.684 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_futures.py
26.424 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_futures2.py
0.678 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_locks.py
33.671 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_pep492.py
6.045 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_proactor_events.py
35.038 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_protocols.py
1.996 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_queues.py
21.159 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_runners.py
5.057 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_selector_events.py
47.165 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_sendfile.py
19.669 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_server.py
3.928 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_sock_lowlevel.py
11.845 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_sslproto.py
25.781 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_streams.py
36.214 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_subprocess.py
25.331 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_tasks.py
107.167 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_transports.py
3.534 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_unix_events.py
66.231 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_windows_events.py
10.5 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
test_windows_utils.py
4.065 KB
6 Sep 2024 8.41 PM
root / linksafe
0644
utils.py
16.829 KB
6 Sep 2024 8.41 PM
root / linksafe
0644

✘✘ GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME ✘✘
Static GIF Static GIF