Skip to content

Tests fail with ruff 0.16 #69

Description

@Ma27

After an update to ruff 0.16, the test_ruff_{ok,error,config} testcases are starting to fail. I've seen ruff 0.16 having added a bunch of new lints, so it looks like that's related, i.e. in the test_ruff_ok-case ruff seems to have something to complain now?

_________________________________ test_ruff_ok _________________________________

pytester = <Pytester PosixPath('/build/pytest-of-nixbld/pytest-0/test_ruff_ok0')>

    def test_ruff_ok(pytester: pytest.Pytester):
        pytester.makefile(
            '.md',
            my_file='```py\nimport sys\nprint(sys.platform)\n```',
        )
        # language=Python
        pytester.makepyfile(
            """
    from pytest_examples import find_examples, CodeExample, EvalExample
    import pytest
    
    @pytest.mark.parametrize('example', find_examples('.'), ids=str)
    def test_find_run_examples(example: CodeExample, eval_example: EvalExample):
        eval_example.lint_ruff(example)
    """
        )
    
        result = pytester.runpytest('-p', 'no:pretty', '-v')
>       result.assert_outcomes(passed=1)
E       AssertionError: assert {'passed': 0,...rors': 0, ...} == {'passed': 1,...rors': 0, ...}
E         
E         Omitting 4 identical items, use -vv to show
E         Differing items:
E         {'failed': 1} != {'failed': 0}
E         {'passed': 0} != {'passed': 1}
E         Use -v to get more diff

/build/source/tests/test_run_examples.py:85: AssertionError
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.14.6, pytest-9.1.1, pluggy-1.6.0 -- /nix/store/rgnappqqc5vbq60gza5fflyk84sylwl6-python3-3.14.6/bin/python3.14
cachedir: .pytest_cache
rootdir: /build/pytest-of-nixbld/pytest-0/test_ruff_ok0
plugins: examples-0.0.18
collecting ... collected 1 item

test_ruff_ok.py::test_find_run_examples[my_file.md:1-4] FAILED           [100%]

=================================== FAILURES ===================================
____________________ test_find_run_examples[my_file.md:1-4] ____________________
ruff failed:
  I001 [*] Import block is un-sorted or un-formatted
   --> my_file.md:2:1
    |
  1 | import sys
    | ^^^^^^^^^^
  2 | print(sys.platform)
    |
  help: Organize imports
    |
  1 | import sys
  2 +
  3 | print(sys.platform)
    |

  Found 1 error.
  [*] 1 fixable with the `--fix` option.

=============================== warnings summary ===============================
../../../../nix/store/hdw07vcf3h94alv8xd2ga5nil4mwgyf3-python3.14-pytest-9.1.1/lib/python3.14/site-packages/_pytest/python.py:124
  /nix/store/hdw07vcf3h94alv8xd2ga5nil4mwgyf3-python3.14-pytest-9.1.1/lib/python3.14/site-packages/_pytest/python.py:124: PytestRemovedIn10Warning: Passing a non-Collection iterable to parametrize is deprecated.
  Test: test_ruff_ok.py::test_find_run_examples, argvalues type: generator
  Please convert to a list or tuple.
  See https://docs.pytest.org/en/stable/deprecations.html#parametrize-iterators
    metafunc.parametrize(*marker.args, **marker.kwargs, _param_mark=marker)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED test_ruff_ok.py::test_find_run_examples[my_file.md:1-4] - Failed: ruff...
========================= 1 failed, 1 warning in 0.01s =========================

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions