cost 122 ms
SQLAlchemy - Pytest - 一个或多个映射器初始化失败 - 无法继续初始化其他映射器 - SQLAlchemy - Pytest - One or more mappers failed to initialize - can't proceed with initialization of other mappers

我正在尝试创建一个数据库,其中包含具有多对多关系的用户和项目表。 一个用户可以是多个项目的一部分,一个项目可以有多个用户。 我为用户、项目和关联表创建了模型,并且能够毫无问题地使用 alembic 创建数据库。 但是,当我尝试使用这些模型时。 它抛出异常sqlalchemy.exc.InvalidR ...

ScopeMismatch 当我尝试进行 setup_teardown pytest function - ScopeMismatch when i try to make setup_teardown pytest function

我的目标是创建一个 fixture,它将在 class function 测试开始时运行一次,并初始化我需要的属性。 为此,我用 class 的 scope 创建了一个 fixture,并直接应用到 class。为了解决 pytest 与异步代码的兼容性问题,使用了 pytest-asyncio。 ...

Pytest + SqlAlchemy + FastAPI。 无法在测试中使用异步引擎获取同步引擎添加的数据 - Pytest + SqlAlchemy + FastAPI. Cannot Get data added by sync engine using async engine in tests

赏金将在 18 小时后到期。 此问题的答案有资格获得+100声望赏金。 fallen想让更多人关注这个问题。 TL;DR在我的应用程序中有 2 个部分。 首先,部分是 API,它只提供数据(有多个 GET 端点)。 其次,事件消费者从 pubsub 消费并写入 db。 我正在为事件消费者使用同 ...

如何使用 pytest-asyncio 对 python 中的异步 function 进行单元测试? - how to unit test an async function in python with pytest-asyncio?

我有一个异步function,向男高音API提出请求。function在另外True 8888年r.status_code == 200 ;它不再有效。 我是 Python 的新手,所以我认为我没有正确使用 async/await 或请求库,但我不知道如何修复此错误。 这是 function: 这 ...

如何在 pytest_sessionfinish() 中调用异步 function? - How to call an async function in pytest_sessionfinish()?

我正在使用pytest-asyncio 。 我有以下conftest.py文件: initialise_db() function 将连接到我的数据库并在我的所有测试运行之前清除其中的所有内容。 现在,我想关闭事件循环并在所有测试完成后关闭与我的数据库的连接。 我尝试将以下 function 添 ...

FastAPI, SQLAlchemy, pytest,无法100%覆盖,没有正常采集 - FastAPI, SQLAlchemy, pytest, unable to get 100% coverage, it doesn't properly collected

我正在尝试使用python 3.9构建完全覆盖测试的FastAPI应用程序 为此,我选择了堆栈:FastAPI、uvicorn、SQLAlchemy、asyncpg、pytest(+ async、cov 插件)、coverage 和 httpx AsyncClient 这是我的最低要求.txt 所有 ...

从 pytest 夹具运行 asyncio 服务器 - Running an asyncio server from a pytest fixture

我正在尝试在 pytest 夹具中使用 asyncio 运行服务器 start方法如下 而一旦尝试打开与服务器的连接,测试就会打印此错误 编辑:问题是事件循环在之后立即关闭,所以我尝试用(scope="module")标记我的所有装置,但现在我得到了 编辑2: 所以我添加了eve ...

多个异步单元测试失败,但一个一个运行它们会通过 - Multiple async unit tests fail, but running them one by one will pass

我有两个单元测试,如果我一个一个运行它们,它们就会通过。 如果我在 class 级别运行它们,一个通过,另一个在response = await ac.post(错误消息: RuntimeError: Event loop is closed 我已经尝试了几个小时,请问我错过了什么? ...

使用 Pytest 测试 Asyncio:如何通过 mocking 事件循环测试 try-except 块? - Testing Asyncio with Pytest: How to test a try-except block by mocking the event loop?

在我正在使用的源代码(此处的源代码链接和此处的WIP PR )中,我试图通过在类的__init__方法中测试try-except块来提高测试覆盖率。 从源代码中剥离额外的代码,相关代码如下所示:# webrtc.py import asyncio from loguru import logge ...


 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM