acceptance_test.py


Overview

The `acceptance_test.py` file is a comprehensive test suite designed to perform acceptance and integration testing on the core functionalities of the `pytest` testing framework itself. It verifies a wide range of scenarios including error handling, configuration issues, plugin loading, invocation variants, fixture behavior, duration reporting, and various edge cases related to test discovery and execution.

This file serves as a critical component ensuring `pytest`'s robustness, user experience, and backward compatibility by simulating real-world usage patterns and failure modes. It leverages the internal testing utilities of `pytest`, particularly the `Pytester` testing helper, to create isolated test environments, run `pytest` commands, and assert expected outcomes.


Key Classes and Functions

Utility Function

prepend_pythonpath(*dirs) -> str


Class: TestGeneralUsage

This class encapsulates multiple test methods that verify general usage scenarios of `pytest`. It covers error reporting, configuration loading, plugin behavior, test discovery, parametrization, and more.


Class: TestInvocationVariants

Tests various ways of invoking `pytest` and ensures consistent behavior.


Class: TestDurations

Tests the `--durations` feature of `pytest` that reports slowest test durations.


Class: TestDurationsWithFixture

Similar to `TestDurations`, but tests duration reporting when tests include fixtures with setup times.


Individual Test Functions

Apart from the classes, the file defines multiple standalone test functions, such as:


Implementation Details and Algorithms


Interaction with Other System Components


Visual Diagram

classDiagram
    class TestGeneralUsage {
        +test_config_error(pytester)
        +test_root_conftest_syntax_error(pytester)
        +test_early_hook_error_issue38_1(pytester)
        +test_early_hook_configure_error_issue38(pytester)
        +test_file_not_found(pytester)
        +test_config_preparse_plugin_option(pytester)
        +test_early_load_setuptools_name(pytester, monkeypatch, load_cov_early)
        +test_assertion_rewrite(pytester, import_mode)
        +test_nested_import_error(pytester)
        +test_better_reporting_on_conftest_load_failure(pytester)
        +test_early_skip(pytester)
        +... (many more)
    }

    class TestInvocationVariants {
        +test_earlyinit(pytester)
        +test_pydoc(pytester)
        +test_import_star_pytest(pytester)
        +test_double_pytestcmdline(pytester)
        +test_python_minus_m_invocation_ok(pytester)
        +test_invoke_with_invalid_type()
        +test_invoke_plugin_api(capsys)
        +test_pyargs_importerror(pytester, monkeypatch)
        +test_cmdline_python_package(pytester, monkeypatch)
        +... (more)
    }

    class TestDurations {
        +test_calls(pytester, mock_timing)
        +test_calls_show_2(pytester, mock_timing)
        +test_calls_showall(pytester, mock_timing)
        +test_with_deselected(pytester, mock_timing)
        +check_tests_in_output(lines, expected_test_numbers, number_of_tests=3)
    }

    class TestDurationsWithFixture {
        +test_setup_function(pytester, mock_timing)
    }

    TestGeneralUsage --> Pytester : uses
    TestInvocationVariants --> Pytester : uses
    TestDurations --> Pytester : uses
    TestDurationsWithFixture --> Pytester : uses

Summary

The `acceptance_test.py` file is an extensive acceptance test suite for the `pytest` testing framework itself. It:

This file is essential for maintaining the quality and reliability of `pytest` as a testing tool, by simulating diverse real-world usage scenarios and failure modes.


End of Documentation for acceptance_test.py