Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests when NO_COLOR is set in the calling environment #12415

Merged
merged 3 commits into from
Mar 3, 2024

Commits on Feb 4, 2024

  1. Fix tests when NO_COLOR is set in the calling environment

    Add `FORCE_COLOR` and `NO_COLOR` variables to the `isolate()` fixture
    to ensure that these two variables do not affect internal test output.
    This fixes the following two test failures when pytest is called with
    `NO_COLOR` set:
    
    ```
    FAILED tests/unit/test_exceptions.py::TestDiagnosticPipErrorPresentation_ASCII::test_complete_color - AssertionError: assert '\x1b[1merror...ing harder.\n' == '\x1b[1;31mer...ing harder.\n'
    FAILED tests/unit/test_exceptions.py::TestDiagnosticPipErrorPresentation_Unicode::test_complete_color - AssertionError: assert '\x1b[1merror...ing harder.\n' == '\x1b[1;31mer...ing harder.\n'
    ```
    mgorny committed Feb 4, 2024
    Configuration menu
    Copy the full SHA
    49d233a View commit details
    Browse the repository at this point in the history
  2. Revert "Stop forcing color in CI"

    This reverts commit 1b33f4b.  Now
    the test suite strips `FORCE_COLOR` internally, so it should be fine
    to run with colors enabled for nox.
    mgorny committed Feb 4, 2024
    Configuration menu
    Copy the full SHA
    f84d782 View commit details
    Browse the repository at this point in the history

Commits on Feb 5, 2024

  1. Lower the scope of simple_script fixture to apply isolate to it

    Lower the scope of `simple_script` fixture used in `test_inspect`
    from `session` to (implicit) `function`, to make it match the `isolate`
    fixture and therefore make the fixture run in isolation.
    Per the documentation [1], pytest initializes higher-scope fixtures
    first, and lower-scope fixtures cannot be used in them.  Since within
    the same scope, autouse fixtures are always loaded before regular
    fixtures, no further adjustment is necessary.  This should have no ill
    side effects, as the fixture is used by a single test only.
    
    [1] https://docs.pytest.org/en/stable/reference/fixtures.html#fixture-instantiation-order
    mgorny committed Feb 5, 2024
    Configuration menu
    Copy the full SHA
    1836651 View commit details
    Browse the repository at this point in the history