deprecated_test.py


Overview

The [deprecated_test.py](/projects/286/67361) file contains a suite of automated tests focused on verifying the behavior of deprecated features, warnings, and APIs within the pytest framework and its related plugins. The primary goal of this file is to ensure that deprecated constructs in pytest, such as old plugin hooks, fixture usage patterns, and path handling, properly emit warnings or errors when used, thus guiding developers towards updated best practices.

This testing module helps maintain backward compatibility while encouraging migration away from deprecated features, supporting a smoother transition between pytest versions.


Detailed Explanations

Imports and Setup


Tests and Their Purpose


test_external_plugins_integrated(pytester: Pytester, plugin) -> None

def test_external_plugins_example(pytester: Pytester):
    # Example plugin name from the deprecated list
    plugin = "deprecated_plugin_name"
    pytester.syspathinsert()
    pytester.makepyfile(**{plugin: ""})
    with pytest.warns(pytest.PytestConfigWarning):
        pytester.parseconfig("-p", plugin)

test_hookspec_via_function_attributes_are_deprecated()


test_hookimpl_via_function_attributes_are_deprecated()


test_yield_fixture_is_deprecated()


test_private_is_deprecated()


test_hookproxy_warnings_for_pathlib(tmp_path, hooktype, request)


test_hookimpl_warnings_for_pathlib()


test_node_ctor_fspath_argument_is_deprecated(pytester: Pytester)


Tests for Fixture and Mark Warnings

These tests ensure that applying pytest marks (like `@pytest.mark.parametrize` or `@pytest.mark.usefixtures`) to fixtures or vice versa warns users because marks on fixtures currently have no effect, which may confuse users.

Each test:


Important Implementation Details and Algorithms


Interactions within the System


Visual Diagram: Class and Test Function Structure

flowchart TD
    A[test_external_plugins_integrated]
    B[test_hookspec_via_function_attributes_are_deprecated]
    C[test_hookimpl_via_function_attributes_are_deprecated]
    D[test_yield_fixture_is_deprecated]
    E[test_private_is_deprecated]
    F[test_hookproxy_warnings_for_pathlib]
    G[test_hookimpl_warnings_for_pathlib]
    H[test_node_ctor_fspath_argument_is_deprecated]
    I[test_fixture_disallow_on_marked_functions]
    J[test_fixture_disallow_marks_on_fixtures]
    K[test_fixture_disallowed_between_marks]

    subgraph Deprecated Features Tests
        A
        B
        C
        D
        E
        F
        G
        H
        I
        J
        K
    end

Summary

[deprecated_test.py](/projects/286/67361) is a critical test module within the pytest codebase that enforces correct deprecation behaviors. By systematically testing various deprecated APIs and usage patterns, it helps maintain the integrity and forward compatibility of pytest. This file's tests serve as both verification and documentation of deprecated features, ensuring developers receive clear guidance and warnings when using outdated constructs.


Additional Notes


If you need further details on any specific test or pytest internals referenced here, please ask!