Ok... I've minimised the problem to asynio issues....
# general
b
Ok... I've minimised the problem to asynio issues. This fails when run on the terminal with
pytest
, and in vscode, but passes with pants:
Copy code
@pytest.mark.asyncio
async def test_foo():
    # await asyncio.sleep(1)
    assert 2 == 4
Commenting or uncommenting the sleep doesn't make a difference. Is there a workaround? Is this a bug?
āœ… 1
b
Do you have the
pytest-asyncio
plugin installed in your Pants resolve?
b
@better-van-82973 thanks... that sounds like what I'm missing, Where would I add that? in pants.toml? Would you happen to have a code snippet?
b
We use Poetry to set up the dev requirements, so the relevant part looks like this:
Copy code
[tool.poetry.group.dev.dependencies]
pytest = "^8.2.0"
ipython = "^8.24.0"
jupyterlab = "^4.0.0"
matplotlib = "^3.6.0"
requests_cache = "^1.0.0"
pytest-mock = "^3.12.0"
faker = "^25.0.0"
pytest-asyncio = "^0.23.0"
Using Pants, you can create a custom resolve for Pytest that includes any test packages you need: https://www.pantsbuild.org/2.21/docs/python/overview/lockfiles#getting-started-with-resolves
b
ah... ao just a standard dev dependency... got it... trying it out.
b
Oh, here is the relevant part of `pants.toml`:
Copy code
[pytest]
args = ["-vv", "-s"]
install_from_resolve = "python-default"
requirements = ["greenlet", "pytest-asyncio", "pytest-cov", "pytest-mock", "pytest-aiohttp"]
The
requirements
field is what passes through the plugins, I’d forgotten about that. Docs here.
b
works... thanks šŸ™‚