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

tests/test_run_examples.py::test_ruff_error fails with latest ruff 0.1.2 #26

Open
GaetanLepage opened this issue Oct 25, 2023 · 0 comments · May be fixed by #28 or #29
Open

tests/test_run_examples.py::test_ruff_error fails with latest ruff 0.1.2 #26

GaetanLepage opened this issue Oct 25, 2023 · 0 comments · May be fixed by #28 or #29

Comments

@GaetanLepage
Copy link

Yesterday ruff 0.1.2 was released.
With this new version, the following test fails:

=================================== FAILURES ===================================
_______________________________ test_ruff_error ________________________________

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

    def test_ruff_error(pytester: pytest.Pytester):
        pytester.makefile(
            '.md',
            my_file='```py\nimport sys\nprint(missing)\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(failed=1)

        output = '\n'.join(result.outlines)
        output = re.sub(r'(=|_){3,}', r'\1\1\1', output)
>       assert (
            '=== FAILURES ===\n'
            '___ test_find_run_examples[my_file.md:1-4] ___\n'
            'ruff failed:\n'
            '  my_file.md:2:8: F401 [*] `sys` imported but unused\n'
            '  my_file.md:3:7: F821 Undefined name `missing`\n'
            '  Found 2 errors.\n'
            '  [*] 1 potentially fixable with the --fix option.\n'
            '=== short test summary info ===\n'
        ) in output
E       AssertionError: assert '=== FAILURES ===\n___ test_find_run_examples[my_file.md:1-4] ___\nruff failed:\n  my_file.md:2:8: F401 [*] `sys` impo...me `missing`\n  Found 2 errors.\n  [*] 1 potentially fixable with the --fix option.\n=== short test summ
ary info ===\n' in '=== test session starts ===\nplatform linux -- Python 3.11.5, pytest-7.4.2, pluggy-1.2.0 -- /nix/store/ffll6glz3gwx34... info ===\nFAILED test_ruff_error.py::test_find_run_examples[my_file.md:1-4] - Failed: r...\n=== 1 failed in 0.02s =
=='

/build/source/tests/test_run_examples.py:108: AssertionError
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.11.5, pytest-7.4.2, pluggy-1.2.0 -- /nix/store/ffll6glz3gwx342z0ch8wx30p5cnqz1z-python3-3.11.5/bin/python3.11
cachedir: .pytest_cache
rootdir: /build/pytest-of-nixbld/pytest-0/test_ruff_error0
plugins: examples-0.0.10
collecting ... collected 1 item

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

=================================== FAILURES ===================================
____________________ test_find_run_examples[my_file.md:1-4] ____________________
ruff failed:
  my_file.md:2:8: F401 [*] `sys` imported but unused
  my_file.md:3:7: F821 Undefined name `missing`
  Found 2 errors.
  [*] 1 fixable with the `--fix` option.
=========================== short test summary info ============================
FAILED test_ruff_error.py::test_find_run_examples[my_file.md:1-4] - Failed: r...
============================== 1 failed in 0.02s ===============================
=========================== short test summary info ============================
FAILED tests/test_run_examples.py::test_ruff_error - AssertionError: assert '=== FAILURES ===\n___ test_find_run_examples[my_fil...
=================== 1 failed, 71 passed, 1 xfailed in 2.07s ====================
@davidhewitt davidhewitt linked a pull request Dec 21, 2023 that will close this issue
@manmartgarc manmartgarc linked a pull request Feb 26, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant