File: class_scoped_loop_example.py

package info (click to toggle)
python-pytest-asyncio 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 644 kB
  • sloc: python: 3,003; makefile: 24; sh: 1
file content (14 lines) | stat: -rw-r--r-- 374 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import asyncio

import pytest


@pytest.mark.asyncio(loop_scope="class")
class TestInOneEventLoopPerClass:
    loop: asyncio.AbstractEventLoop

    async def test_remember_loop(self):
        TestInOneEventLoopPerClass.loop = asyncio.get_running_loop()

    async def test_assert_same_loop(self):
        assert asyncio.get_running_loop() is TestInOneEventLoopPerClass.loop