pytest-dev/pytest-asyncio

Cannot add pytest-asyncio as dependency when using poetry

Closed this issue · 3 comments

When pytest-asyncio is added as a dependency under pyproject.toml. The lock generation continues infinitely.

Steps to reproduce the issue:

Use below pyproject.toml

[tool.poetry]
name = "test_package"
version = "0.1.0"
description = ""
authors = [""]

[tool.poetry.dependencies]
python = "~3.10.16"

[tool.poetry.dev-dependencies]
pytest-asyncio = "*"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

Generate lock with command: poetry lock -vvv

Output:

...
   1: selecting backports.asyncio.runner (1.2.0)
   1: selecting backports.asyncio.runner (1.2.0)
   1: selecting backports.asyncio.runner (1.2.0)
   1: selecting backports.asyncio.runner (1.2.0)
...

The lock generation happens infinitely printing: 1: selecting backports.asyncio.runner (1.2.0)

Suspected cause:

The issue might have started after adding this line in pyproject.toml
"backports-asyncio-runner>=1.1,<2; python_version<'3.11'",

Thanks for reaching out and for the reproducer.
I tried to reproduce this with Poetry 1.8.4 and Poetry 2.1.3 and I cannot reproduce the issue. The lockfile is always generated without issue. I don't see anything that's obviously wrong with the dependency specification in pyproject.toml either.

It is very unlikely that this is a pytest-asyncio bug.

@ashinkajay Which version of Poetry do you use? Can you check if there's anything in your Poetry configuration that could affect the dependency resolution? Any Poetry plugins that are installed?

@seifertm Thanks for checking.
I also tried with poetry version 2.1.3. It's not happening there.
I'm using Poetry version 1.1.15. I haven't made any changes in poetry configs after installation.

@ashinkajay This is likely an issue with Poetry than with pytest-asyncio. I suggest you flag the issue there, if the v1.1 line is still supported.

Since the pytest-asyncio installation works with pip and a bunch of other tools, I don't think a workaround on pytest-asyncio for an old Poetry version is warranted.