【发布时间】:2022-02-06 14:40:02
【问题描述】:
我有以下课程,我正在 method2 上写一个测试。
y.py
class C:
@classmethod
async def method1(cls): # to be mocked
pass
@classmethod
async def method2(cls): # to be tested
await cls.method1()
我有以下
from asyncio import Future
from unittest.mock import Mock
import pytest
from y import C
@pytest.mark.asyncio
async def test_method2():
C.method1 = Mock(return_value=Future())
await C.method2()
C.method1.assert_called_once()
但是,在运行python -m pytest test.py时会挂起?
【问题讨论】:
标签: python pytest python-unittest