File: module_scoped_loop_strict_mode_example.py

package info (click to toggle)
python-pytest-asyncio 1.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 616 kB
  • sloc: python: 2,421; makefile: 24; sh: 1
file content (23 lines) | stat: -rw-r--r-- 450 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import asyncio

import pytest

pytestmark = pytest.mark.asyncio(loop_scope="module")

loop: asyncio.AbstractEventLoop


async def test_remember_loop():
    global loop
    loop = asyncio.get_running_loop()


async def test_this_runs_in_same_loop():
    global loop
    assert asyncio.get_running_loop() is loop


class TestClassA:
    async def test_this_runs_in_same_loop(self):
        global loop
        assert asyncio.get_running_loop() is loop