When using with the most recent version of pytest 8.2.0, asyncio-0.21.1 is used which breaks the fixtures with error: AttributeError: 'FixtureDef' object has no attribute 'unittest'.
To reproduce:
Minimal tox.ini in project root.
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
[tox]
skipsdist=True
skip_missing_interpreters = True
envlist = unit
When using with the most recent version of pytest 8.2.0,
asyncio-0.21.1
is used which breaks the fixtures with error:AttributeError: 'FixtureDef' object has no attribute 'unittest'
.To reproduce:
tox.ini
in project root.[tox] skipsdist=True skip_missing_interpreters = True envlist = unit
[vars] src_path = {toxinidir}/src/ tst_path = {toxinidir}/tests/ ;lib_path = {toxinidir}/lib/charms/operator_name_with_underscores all_path = {[vars]src_path} {[vars]tst_path}
[testenv] basepython = python3.10 setenv = PYTHONPATH = {toxinidir}:{toxinidir}/lib:{[vars]src_path} PYTHONBREAKPOINT=ipdb.set_trace PY_COLORS=1 passenv = PYTHONPATH
[testenv:integration] description = Run integration tests pass_env = PYTEST_ADDOPTS deps = pytest pytest-asyncio pytest-operator commands = pytest -v --tb native --log-cli-level=INFO
import logging
import pytest import pytest_asyncio
logger = logging.getLogger(name)
@pytest_asyncio.fixture(name="buggy") async def async_fixture(): logger.info("SETUP FIXTURE") return "buggy"
@pytest.mark.asyncio async def test_buggy(buggy): logger.info("TESTING") print(f"hello {buggy}")