Skip to content

[BUG] pytest 10 will break install-script tests: class-scoped fixture defined as instance method #691

Closed

Description

@c-vigo

Description

The test suite emits a PytestRemovedIn10Warning from the class-scoped install_workspace fixture in tests/test_install_script.py:

PytestRemovedIn10Warning: Class-scoped fixture defined as instance method is deprecated.
Instance attributes set in this fixture will NOT be visible to test methods,
as each test gets a new instance while the fixture runs only once per class.
Use @classmethod decorator and set attributes on cls instead.

Today this is cosmetic — the fixture only yields a value that the 17 tests consume via the fixture parameter; it never sets self. attributes that tests read, and warnings are not escalated to errors. But it is latent forward-breakage: the project pins pytest==9.1.1, and pytest 10 removes this pattern. When Renovate/Dependabot bumps pytest to 10, the fixture will error at collection and take out the entire TestInstallScriptIntegration suite.

Filing as low-priority to fix proactively before the pytest 10 bump lands.

Steps to Reproduce

  1. Run any test that touches TestInstallScriptIntegration, e.g.:
    TEST_CONTAINER_TAG=dev uv run pytest tests/test_install_script.py -v
  2. Observe the PytestRemovedIn10Warning in the warnings summary.
  3. To confirm it will break under pytest 10, escalate it to an error:
    TEST_CONTAINER_TAG=dev uv run pytest tests/test_install_script.py -W error::pytest.PytestRemovedIn10Warning

Expected Behavior

No deprecation warning; the install-script integration tests remain collectable and green under pytest 9 and 10.

Actual Behavior

PytestRemovedIn10Warning is emitted. Under a future pytest 10, the deprecated pattern is removed and collection of TestInstallScriptIntegration fails.

Environment

  • OS: NixOS 26.05 (Yarara)
  • pytest: 9.1.1 (pinned in pyproject.toml)
  • Architecture: x86_64

Root cause

tests/test_install_script.py:32 defines a class-scoped fixture as an instance method:

class TestInstallScriptIntegration:
    @pytest.fixture(scope="class")
    def install_workspace(self, container_image):
        ...
        yield workspace_path

pytest deprecated (and will remove in v10) class-scoped fixtures defined as instance methods, because each test gets a fresh instance while the fixture runs once per class — making self-based state unreliable. This is the only fixture in tests/ matching the pattern (conftest, test_integration, test_utils, test_image, test_flake_devshell are all clear).

Suggested fix

Convert install_workspace so it no longer relies on the deprecated instance-method form, while preserving the "run install.sh once per class" intent. Either:

  1. Make it a @classmethod (or @staticmethod) keeping scope="class", taking container_image as a fixture arg and yield-ing as today (no self); or
  2. Lift it to a module-level fixture (scope="module" ≈ class scope here, since only one class uses it).

Tests already consume it via the fixture parameter, so no test-method changes are needed.

Verify the fix with the warning escalated to an error:

TEST_CONTAINER_TAG=dev uv run pytest tests/test_install_script.py \
  -W error::pytest.PytestRemovedIn10Warning -v --tb=short

Changelog Category

Fixed

Activity

  1. added
    bug
    priority:low
    area:ci
    effort:small
    semver:patch
    on Jun 24, 2026
  2. self-assigned this
    on Jun 24, 2026
  3. c-vigo commented on Jul 1, 2026

    @c-vigo
    ContributorAuthor

    Already resolved on dev. tests/test_install_script.py now decorates install_workspace with @staticmethod under @pytest.fixture(scope="class") (landed in d99765c6, fix(ci): make install_workspace a staticmethod fixture), so the class-scoped-instance-method pattern is gone and the suite is pytest-10-safe. Closing as done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:cibugeffort:smallpriority:lowsemver:patch

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions