0

我正在尝试做一些集成测试,我直接调用本地数据库。我有 2 个测试一个接一个地执行,但是我收到以下错误。

E RuntimeError: Task <Task pending name='Task-3' coro=<TestDB.test_priority() running at /home/kay/checkpoint/entity-extractor/test/test_db.py:21> cb=[_run_until_complete_cb() at /usr/lib/python3.8/asyncio/base_events.py:184]> 将 Future 附加到另一个循环

/usr/lib/python3.8/asyncio/streams.py:517:运行时错误

==================================================== ============================================ 警告总结 ===== ==================================================== ======================================= test/test_db.py::TestDB::test_db
/ home/kay/.local/share/virtualenvs/entity-extractor-BuK_iA9e/lib/python3.8/site-packages/aiomysql/pool.py:46:DeprecationWarning:循环参数自 Python 3.8 起已弃用,并计划删除在 Python 3.10 中。self._cond = asyncio.Condition(loop=loop)

test/test_db.py::TestDB::test_db
/usr/lib/python3.8/asyncio/locks.py:335: DeprecationWarning: 自 Python 3.8 以来不推荐使用循环参数,并计划在 Python 3.10 中删除。锁=锁(循环=循环)

test/test_db.py::TestDB::test_db
/usr/lib/python3.8/asyncio/tasks.py:455: DeprecationWarning: 自 Python 3.8 以来不推荐使用循环参数,并计划在 Python 3.10 中删除。返回等待未来

-- 文档:https : //docs.pytest.org/en/stable/warnings.html ============================= ==================================================== ========== 简短的测试摘要信息 ===================================== ==================================================== ==== FAILED test/test_db.py::TestDB::test_priority - RuntimeError: Task <Task pending name='Task-3' coro=<TestDB.test_priority()

如果我单独运行测试,它们会起作用。我正在使用 aio-libs 中的一些工具来执行测试。pytest、pytest-asyncio 和 aiomysql。

test_db.py

import pytest

from src.app.checkpointdb import get_entity_priorities, get_social_tags


class TestDB:
    @pytest.mark.asyncio
    async def test_db(self):

        list_of_entities = ["e01263a1-569e-439d-b711-7b23fcd0e6e4"]

        tags = await get_social_tags(list_of_entities)

    @pytest.mark.asyncio
    async def test_priority(self):

        data = ["Fnatic"]

        prioties = await get_entity_priorities(data)

4

0 回答 0