pax_global_header00006660000000000000000000000064147067331700014522gustar00rootroot0000000000000052 comment=b82e669e0ee2420e656d31a144909dd63c6a0e1b pytest-flake8-path-1.6.0/000077500000000000000000000000001470673317000151605ustar00rootroot00000000000000pytest-flake8-path-1.6.0/.editorconfig000066400000000000000000000003451470673317000176370ustar00rootroot00000000000000# http://editorconfig.org root = true [*] indent_style = space indent_size = 2 trim_trailing_whitespace = true insert_final_newline = true charset = utf-8 end_of_line = lf [*.py] indent_size = 4 [Makefile] indent_style = tab pytest-flake8-path-1.6.0/.github/000077500000000000000000000000001470673317000165205ustar00rootroot00000000000000pytest-flake8-path-1.6.0/.github/CODE_OF_CONDUCT.md000066400000000000000000000001311470673317000213120ustar00rootroot00000000000000This project follows [Django's Code of Conduct](https://www.djangoproject.com/conduct/). pytest-flake8-path-1.6.0/.github/ISSUE_TEMPLATE/000077500000000000000000000000001470673317000207035ustar00rootroot00000000000000pytest-flake8-path-1.6.0/.github/ISSUE_TEMPLATE/config.yml000066400000000000000000000000341470673317000226700ustar00rootroot00000000000000blank_issues_enabled: false pytest-flake8-path-1.6.0/.github/ISSUE_TEMPLATE/feature-request.yml000066400000000000000000000004111470673317000245430ustar00rootroot00000000000000name: Feature Request description: Request an enhancement or new feature. body: - type: textarea id: description attributes: label: Description description: Please describe your feature request with appropriate detail. validations: required: true pytest-flake8-path-1.6.0/.github/ISSUE_TEMPLATE/issue.yml000066400000000000000000000015261470673317000225620ustar00rootroot00000000000000name: Issue description: File an issue body: - type: input id: python_version attributes: label: Python Version description: Which version of Python were you using? placeholder: 3.9.0 validations: required: false - type: input id: pytest_version attributes: label: pytest Version description: Which version of pytest were you using? placeholder: 6.2.4 validations: required: false - type: input id: package_version attributes: label: Package Version description: Which version of this package were you using? If not the latest version, please check this issue has not since been resolved. placeholder: 1.0.0 validations: required: false - type: textarea id: description attributes: label: Description description: Please describe your issue. validations: required: true pytest-flake8-path-1.6.0/.github/SECURITY.md000066400000000000000000000001011470673317000203010ustar00rootroot00000000000000Please report security issues directly over email to me@adamj.eu pytest-flake8-path-1.6.0/.github/dependabot.yml000066400000000000000000000002471470673317000213530ustar00rootroot00000000000000version: 2 updates: - package-ecosystem: github-actions directory: "/" groups: "GitHub Actions": patterns: - "*" schedule: interval: monthly pytest-flake8-path-1.6.0/.github/workflows/000077500000000000000000000000001470673317000205555ustar00rootroot00000000000000pytest-flake8-path-1.6.0/.github/workflows/main.yml000066400000000000000000000024521470673317000222270ustar00rootroot00000000000000name: CI on: push: branches: - main tags: - '**' pull_request: concurrency: group: ${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: tests: name: Python ${{ matrix.python-version }} runs-on: ubuntu-24.04 strategy: matrix: python-version: - 3.9 - '3.10' - '3.11' - '3.12' - '3.13' steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} allow-prereleases: true - name: Install uv uses: astral-sh/setup-uv@v3 with: enable-cache: true cache-dependency-glob: tests/requirements/*.txt - name: Install dependencies run: uv pip install --system tox tox-uv - name: Run tox targets for ${{ matrix.python-version }} run: tox run -f py$(echo ${{ matrix.python-version }} | tr -d .) release: needs: [tests] if: success() && startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-24.04 environment: release permissions: contents: read id-token: write steps: - uses: actions/checkout@v4 - uses: astral-sh/setup-uv@v3 - name: Build run: uv build - uses: pypa/gh-action-pypi-publish@release/v1 pytest-flake8-path-1.6.0/.gitignore000066400000000000000000000000771470673317000171540ustar00rootroot00000000000000*.egg-info/ *.pyc /.coverage /.coverage.* /.tox /build/ /dist/ pytest-flake8-path-1.6.0/.pre-commit-config.yaml000066400000000000000000000027111470673317000214420ustar00rootroot00000000000000ci: autoupdate_schedule: monthly default_language_version: python: python3.12 repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v5.0.0 hooks: - id: check-added-large-files - id: check-case-conflict - id: check-json - id: check-merge-conflict - id: check-symlinks - id: check-toml - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/tox-dev/pyproject-fmt rev: 2.2.4 hooks: - id: pyproject-fmt - repo: https://github.com/tox-dev/tox-ini-fmt rev: 1.4.1 hooks: - id: tox-ini-fmt - repo: https://github.com/rstcheck/rstcheck rev: v6.2.4 hooks: - id: rstcheck additional_dependencies: - tomli==2.0.1 - repo: https://github.com/asottile/pyupgrade rev: v3.17.0 hooks: - id: pyupgrade args: [--py39-plus] - repo: https://github.com/psf/black-pre-commit-mirror rev: 24.10.0 hooks: - id: black - repo: https://github.com/adamchainz/blacken-docs rev: 1.18.0 hooks: - id: blacken-docs additional_dependencies: - black==23.1.0 - repo: https://github.com/pycqa/isort rev: 5.13.2 hooks: - id: isort name: isort (python) - repo: https://github.com/PyCQA/flake8 rev: 7.1.1 hooks: - id: flake8 additional_dependencies: - flake8-bugbear - flake8-comprehensions - flake8-logging - flake8-tidy-imports - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.11.2 hooks: - id: mypy additional_dependencies: - pytest==7.1.2 pytest-flake8-path-1.6.0/CHANGELOG.rst000066400000000000000000000014261470673317000172040ustar00rootroot00000000000000========= Changelog ========= 1.6.0 (2024-10-25) ------------------ * Drop Python 3.8 support. * Support Python 3.13. 1.5.0 (2023-07-10) ------------------ * Drop Python 3.7 support. 1.4.0 (2023-06-16) ------------------ * Support Python 3.12. 1.3.0 (2022-05-11) ------------------ * Support Python 3.11. 1.2.0 (2022-01-10) ------------------ * Drop Python 3.6 support. 1.1.0 (2021-08-11) ------------------ * Normalize file paths in output on Windows to Unix format. This allows test suites to run the same on all operating systems. Fixes `pytest-flake8dir Issue #103 `__. 1.0.0 (2021-08-10) ------------------ * Initial release, ported from `pytest-flake8dir `__. pytest-flake8-path-1.6.0/HISTORY.rst000066400000000000000000000001151470673317000170500ustar00rootroot00000000000000See https://github.com/adamchainz/pytest-flake8-path/blob/main/CHANGELOG.rst pytest-flake8-path-1.6.0/LICENSE000066400000000000000000000020551470673317000161670ustar00rootroot00000000000000MIT License Copyright (c) 2021 Adam Johnson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. pytest-flake8-path-1.6.0/MANIFEST.in000066400000000000000000000001631470673317000167160ustar00rootroot00000000000000prune tests include CHANGELOG.rst include LICENSE include pyproject.toml include README.rst include src/*/py.typed pytest-flake8-path-1.6.0/README.rst000066400000000000000000000140751470673317000166560ustar00rootroot00000000000000================== pytest-flake8-path ================== .. image:: https://img.shields.io/github/actions/workflow/status/adamchainz/pytest-flake8-path/main.yml.svg?branch=main&style=for-the-badge :target: https://github.com/adamchainz/pytest-flake8-path/actions?workflow=CI .. image:: https://img.shields.io/pypi/v/pytest-flake8-path.svg?style=for-the-badge :target: https://pypi.org/project/pytest-flake8-path/ .. image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge :target: https://github.com/psf/black .. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=for-the-badge :target: https://github.com/pre-commit/pre-commit :alt: pre-commit A pytest fixture for testing flake8 plugins. A quick example: .. code-block:: python def test_simple_run(flake8_path): (flake8_path / "example.py").write_text("x = 1\n") result = flake8_path.run_flake8() assert result.out_lines == [ "./example.py:1:2: E221 multiple spaces before operator" ] ---- **Working on a Django project?** Check out my book `Speed Up Your Django Tests `__ which covers loads of ways to write faster, more accurate tests. ---- Installation ============ Use **pip**: .. code-block:: sh python -m pip install pytest-flake8-path Python 3.9 to 3.13 supported. API === ``flake8_path`` fixture ----------------------- A pytest fixture that wraps Pytest's built-in ``tmp_path`` fixture (`docs `__), to create a temporary directory, allow adding files, and running flake8. It acts like a `pathlib.Path `__ object, with one extra method. If you're using this to test a flake8 plugin, make sure flake8 is picking up your plugin during tests. Normally this is done with a ``setup.cfg`` entrypoint, which makes ``tox`` the easiest way to guarantee this is ready as it will install your project before running tests. ``flake8dir.run_flake8(extra_args: list[str] | None = None) -> Flake8Result`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Runs flake8 and returns a ``Flake8Result`` representing the results. ``extra_args`` may be a list of extra flags to pass to flake8, for example passing ``["--ignore", "E101"]``. Note some arguments are already passed to ensure Flake8 runs in an isolated manner - see source. ``Flake8Result`` ---------------- Represents the parsed output of a flake8 run. ``Flake8Result.out: str`` ~~~~~~~~~~~~~~~~~~~~~~~~~ The full string of output (stdout) generated by flake8. ``Flake8Result.err: str`` ~~~~~~~~~~~~~~~~~~~~~~~~~ The full string of error output (stderr) generated by flake8. ``Flake8Result.exit_code: int`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The exit code that the flake8 run exited with. ``Flake8Result.out_lines: list[str]`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A list of individual lines of output, without trailing newlines. This is the most useful tool for making assertions against. On Windows, file paths are normalized into the Unix format (``\`` is replaced with ``/``). This allows test suites to run the same on all operating systems. For example, given a result you can check for a particular line being output: .. code-block:: python result = flake8_path.run_flake8() expected = "./example.py:1:2: E221 multiple spaces before operator" assert expected in result.out_lines ``Flake8Result.err_lines: list[str]`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Like ``out_lines``, but for error output. Examples ======== Basic ----- Using ``Path.write_text()`` (`docs `__) we can create an ``example.py`` file with code. Then with ``flake8_path.run_flake8()`` we can run flake8 and check for an expected error: .. code-block:: python def test_simple(flake8_path): (flake8_path / "example.py").write_text("x = 1\n") result = flake8_path.run_flake8() assert result.out_lines == [ "./example.py:1:2: E221 multiple spaces before operator" ] assert result.err_lines == [] assert result.exit_code == 1 With dedent ----------- The standard library’s ``textwrap.dedent()`` (`docs `__) is useful for including multi-line files. Use a triple quoted multi-line string, with an initial backslash to prevent a blank first line: .. code-block:: python def test_multi_line(flake8_path): (flake8_path / "example.py").write_text( dedent( """\ x = 1 y = 2 """ ) ) result = flake8_path.run_flake8() assert result.out_lines == [ "./example.py:1:2: E221 multiple spaces before operator", "./example.py:2:2: E221 multiple spaces before operator", ] assert result.err_lines == [] assert result.exit_code == 1 Configuring flake8 ------------------ Write a ``setup.cfg`` file to configure flake8 before running it: .. code-block:: python def test_with_setup_cfg(flake8_path): (flake8_path / "setup.cfg").write_text( dedent( """\ [flake8] ignore = E221 """ ) ) (flake8_path / "example.py").write_text("x = 1\n") result = flake8_path.run_flake8() assert result.out_lines == [] assert result.err_lines == [] assert result.exit_code == 0 History ======= pytest-flake8-path is the successor to `pytest-flake8dir `__. pytest-flake8dir was based upon pytest’s ``tmpdir`` fixture, which returned a legacy ``py.path.local`` object. Since version 3.9.0, pytest has provided the ``tmp_path`` fixture, which returns a standard library ``pathlib.Path`` object. pytest-flake8-path is a rewrite of pytest-flake8dir to use ``tmp_path`` instead of ``tmpdir``. pytest-flake8-path-1.6.0/pyproject.toml000066400000000000000000000033431470673317000200770ustar00rootroot00000000000000[build-system] build-backend = "setuptools.build_meta" requires = [ "setuptools", ] [project] name = "pytest-flake8-path" version = "1.6.0" description = "A pytest fixture for testing flake8 plugins." readme = "README.rst" keywords = [ "flake8", "pytest", ] authors = [ { name = "Adam Johnson", email = "me@adamj.eu" }, ] requires-python = ">=3.9" classifiers = [ "Development Status :: 5 - Production/Stable", "Framework :: Pytest", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Typing :: Typed", ] dependencies = [ "flake8", "pytest", ] urls = { Changelog = "https://github.com/adamchainz/pytest-flake8-path/blob/main/CHANGELOG.rst", Funding = "https://adamj.eu/books/", Repository = "https://github.com/adamchainz/pytest-flake8-path" } entry-points.pytest11.flake8_path = "pytest_flake8_path" [tool.isort] add_imports = [ "from __future__ import annotations", ] force_single_line = true profile = "black" [tool.pyproject-fmt] max_supported_python = "3.13" [tool.pytest.ini_options] addopts = """\ --strict-config --strict-markers """ xfail_strict = true [tool.mypy] enable_error_code = [ "ignore-without-code", "redundant-expr", "truthy-bool", ] mypy_path = "src/" namespace_packages = false strict = true warn_unreachable = true [[tool.mypy.overrides]] module = "tests.*" allow_untyped_defs = true [tool.rstcheck] report_level = "ERROR" pytest-flake8-path-1.6.0/src/000077500000000000000000000000001470673317000157475ustar00rootroot00000000000000pytest-flake8-path-1.6.0/src/pytest_flake8_path/000077500000000000000000000000001470673317000215455ustar00rootroot00000000000000pytest-flake8-path-1.6.0/src/pytest_flake8_path/__init__.py000066400000000000000000000034541470673317000236640ustar00rootroot00000000000000from __future__ import annotations import subprocess import sys from collections.abc import Generator from pathlib import Path from typing import TYPE_CHECKING import pytest from _pytest.tmpdir import TempPathFactory class Flake8Result: def __init__(self, out: str, err: str, exit_code: int) -> None: self.out = out self.out_lines: list[str] = [] for line in out.strip().splitlines(): if ":" in line: filename, rest = line.split(":", 1) norm_filename = filename.replace("\\", "/") self.out_lines.append(f"{norm_filename}:{rest}") else: self.out_lines.append(line) self.err = err self.err_lines = err.strip().splitlines() self.exit_code = exit_code if TYPE_CHECKING: BasePathType = Path else: # Have to extend concrete type, which is determined in Path.__new__ BasePathType = type(Path()) class Flake8Path(BasePathType): def run_flake8(self, extra_args: list[str] | None = None) -> Flake8Result: args = [ sys.executable, "-m", "flake8", "--jobs", "1", "--config", "setup.cfg", ".", ] if extra_args: args.extend(extra_args) process = subprocess.run( args=args, cwd=str(self), capture_output=True, text=True, ) return Flake8Result( out=process.stdout, err=process.stderr, exit_code=process.returncode, ) @pytest.fixture def flake8_path(tmp_path_factory: TempPathFactory) -> Generator[Flake8Path]: path = Flake8Path(tmp_path_factory.mktemp("flake8_path")) (path / "setup.cfg").write_text("[flake8]\n") yield path pytest-flake8-path-1.6.0/src/pytest_flake8_path/py.typed000066400000000000000000000000001470673317000232320ustar00rootroot00000000000000pytest-flake8-path-1.6.0/tests/000077500000000000000000000000001470673317000163225ustar00rootroot00000000000000pytest-flake8-path-1.6.0/tests/__init__.py000066400000000000000000000000001470673317000204210ustar00rootroot00000000000000pytest-flake8-path-1.6.0/tests/requirements/000077500000000000000000000000001470673317000210455ustar00rootroot00000000000000pytest-flake8-path-1.6.0/tests/requirements/compile.py000077500000000000000000000014421470673317000230530ustar00rootroot00000000000000#!/usr/bin/env python from __future__ import annotations import os import subprocess import sys from functools import partial from pathlib import Path if __name__ == "__main__": os.chdir(Path(__file__).parent) common_args = [ "uv", "pip", "compile", "--quiet", "--generate-hashes", "requirements.in", *sys.argv[1:], ] run = partial(subprocess.run, check=True) run([*common_args, "--python", "3.9", "--output-file", "py39.txt"]) run([*common_args, "--python", "3.10", "--output-file", "py310.txt"]) run([*common_args, "--python", "3.11", "--output-file", "py311.txt"]) run([*common_args, "--python", "3.12", "--output-file", "py312.txt"]) run([*common_args, "--python", "3.13", "--output-file", "py313.txt"]) pytest-flake8-path-1.6.0/tests/requirements/py310.txt000066400000000000000000000046401470673317000224660ustar00rootroot00000000000000# This file was autogenerated by uv via the following command: # uv pip compile --generate-hashes requirements.in --python 3.10 --output-file py310.txt exceptiongroup==1.2.2 \ --hash=sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b \ --hash=sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc # via pytest flake8==7.1.1 \ --hash=sha256:049d058491e228e03e67b390f311bbf88fce2dbaa8fa673e7aea87b7198b8d38 \ --hash=sha256:597477df7860daa5aa0fdd84bf5208a043ab96b8e96ab708770ae0364dd03213 # via -r requirements.in iniconfig==2.0.0 \ --hash=sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3 \ --hash=sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374 # via pytest mccabe==0.7.0 \ --hash=sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325 \ --hash=sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e # via flake8 packaging==24.1 \ --hash=sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002 \ --hash=sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124 # via pytest pluggy==1.5.0 \ --hash=sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1 \ --hash=sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669 # via pytest pycodestyle==2.12.1 \ --hash=sha256:46f0fb92069a7c28ab7bb558f05bfc0110dac69a0cd23c61ea0040283a9d78b3 \ --hash=sha256:6838eae08bbce4f6accd5d5572075c63626a15ee3e6f842df996bf62f6d73521 # via flake8 pyflakes==3.2.0 \ --hash=sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f \ --hash=sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a # via flake8 pytest==8.3.2 \ --hash=sha256:4ba08f9ae7dcf84ded419494d229b48d0903ea6407b030eaec46df5e6a73bba5 \ --hash=sha256:c132345d12ce551242c87269de812483f5bcc87cdbb4722e48487ba194f9fdce # via # -r requirements.in # pytest-randomly pytest-randomly==3.15.0 \ --hash=sha256:0516f4344b29f4e9cdae8bce31c4aeebf59d0b9ef05927c33354ff3859eeeca6 \ --hash=sha256:b908529648667ba5e54723088edd6f82252f540cc340d748d1fa985539687047 # via -r requirements.in tomli==2.0.1 \ --hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \ --hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f # via pytest pytest-flake8-path-1.6.0/tests/requirements/py311.txt000066400000000000000000000040071470673317000224640ustar00rootroot00000000000000# This file was autogenerated by uv via the following command: # uv pip compile --generate-hashes requirements.in --python 3.11 --output-file py311.txt flake8==7.1.1 \ --hash=sha256:049d058491e228e03e67b390f311bbf88fce2dbaa8fa673e7aea87b7198b8d38 \ --hash=sha256:597477df7860daa5aa0fdd84bf5208a043ab96b8e96ab708770ae0364dd03213 # via -r requirements.in iniconfig==2.0.0 \ --hash=sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3 \ --hash=sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374 # via pytest mccabe==0.7.0 \ --hash=sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325 \ --hash=sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e # via flake8 packaging==24.1 \ --hash=sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002 \ --hash=sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124 # via pytest pluggy==1.5.0 \ --hash=sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1 \ --hash=sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669 # via pytest pycodestyle==2.12.1 \ --hash=sha256:46f0fb92069a7c28ab7bb558f05bfc0110dac69a0cd23c61ea0040283a9d78b3 \ --hash=sha256:6838eae08bbce4f6accd5d5572075c63626a15ee3e6f842df996bf62f6d73521 # via flake8 pyflakes==3.2.0 \ --hash=sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f \ --hash=sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a # via flake8 pytest==8.3.2 \ --hash=sha256:4ba08f9ae7dcf84ded419494d229b48d0903ea6407b030eaec46df5e6a73bba5 \ --hash=sha256:c132345d12ce551242c87269de812483f5bcc87cdbb4722e48487ba194f9fdce # via # -r requirements.in # pytest-randomly pytest-randomly==3.15.0 \ --hash=sha256:0516f4344b29f4e9cdae8bce31c4aeebf59d0b9ef05927c33354ff3859eeeca6 \ --hash=sha256:b908529648667ba5e54723088edd6f82252f540cc340d748d1fa985539687047 # via -r requirements.in pytest-flake8-path-1.6.0/tests/requirements/py312.txt000066400000000000000000000040071470673317000224650ustar00rootroot00000000000000# This file was autogenerated by uv via the following command: # uv pip compile --generate-hashes requirements.in --python 3.12 --output-file py312.txt flake8==7.1.1 \ --hash=sha256:049d058491e228e03e67b390f311bbf88fce2dbaa8fa673e7aea87b7198b8d38 \ --hash=sha256:597477df7860daa5aa0fdd84bf5208a043ab96b8e96ab708770ae0364dd03213 # via -r requirements.in iniconfig==2.0.0 \ --hash=sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3 \ --hash=sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374 # via pytest mccabe==0.7.0 \ --hash=sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325 \ --hash=sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e # via flake8 packaging==24.1 \ --hash=sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002 \ --hash=sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124 # via pytest pluggy==1.5.0 \ --hash=sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1 \ --hash=sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669 # via pytest pycodestyle==2.12.1 \ --hash=sha256:46f0fb92069a7c28ab7bb558f05bfc0110dac69a0cd23c61ea0040283a9d78b3 \ --hash=sha256:6838eae08bbce4f6accd5d5572075c63626a15ee3e6f842df996bf62f6d73521 # via flake8 pyflakes==3.2.0 \ --hash=sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f \ --hash=sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a # via flake8 pytest==8.3.2 \ --hash=sha256:4ba08f9ae7dcf84ded419494d229b48d0903ea6407b030eaec46df5e6a73bba5 \ --hash=sha256:c132345d12ce551242c87269de812483f5bcc87cdbb4722e48487ba194f9fdce # via # -r requirements.in # pytest-randomly pytest-randomly==3.15.0 \ --hash=sha256:0516f4344b29f4e9cdae8bce31c4aeebf59d0b9ef05927c33354ff3859eeeca6 \ --hash=sha256:b908529648667ba5e54723088edd6f82252f540cc340d748d1fa985539687047 # via -r requirements.in pytest-flake8-path-1.6.0/tests/requirements/py313.txt000066400000000000000000000040071470673317000224660ustar00rootroot00000000000000# This file was autogenerated by uv via the following command: # uv pip compile --generate-hashes requirements.in --python 3.13 --output-file py313.txt flake8==7.1.1 \ --hash=sha256:049d058491e228e03e67b390f311bbf88fce2dbaa8fa673e7aea87b7198b8d38 \ --hash=sha256:597477df7860daa5aa0fdd84bf5208a043ab96b8e96ab708770ae0364dd03213 # via -r requirements.in iniconfig==2.0.0 \ --hash=sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3 \ --hash=sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374 # via pytest mccabe==0.7.0 \ --hash=sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325 \ --hash=sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e # via flake8 packaging==24.1 \ --hash=sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002 \ --hash=sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124 # via pytest pluggy==1.5.0 \ --hash=sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1 \ --hash=sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669 # via pytest pycodestyle==2.12.1 \ --hash=sha256:46f0fb92069a7c28ab7bb558f05bfc0110dac69a0cd23c61ea0040283a9d78b3 \ --hash=sha256:6838eae08bbce4f6accd5d5572075c63626a15ee3e6f842df996bf62f6d73521 # via flake8 pyflakes==3.2.0 \ --hash=sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f \ --hash=sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a # via flake8 pytest==8.3.2 \ --hash=sha256:4ba08f9ae7dcf84ded419494d229b48d0903ea6407b030eaec46df5e6a73bba5 \ --hash=sha256:c132345d12ce551242c87269de812483f5bcc87cdbb4722e48487ba194f9fdce # via # -r requirements.in # pytest-randomly pytest-randomly==3.15.0 \ --hash=sha256:0516f4344b29f4e9cdae8bce31c4aeebf59d0b9ef05927c33354ff3859eeeca6 \ --hash=sha256:b908529648667ba5e54723088edd6f82252f540cc340d748d1fa985539687047 # via -r requirements.in pytest-flake8-path-1.6.0/tests/requirements/py39.txt000066400000000000000000000055201470673317000224140ustar00rootroot00000000000000# This file was autogenerated by uv via the following command: # uv pip compile --generate-hashes requirements.in --python 3.9 --output-file py39.txt exceptiongroup==1.2.2 \ --hash=sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b \ --hash=sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc # via pytest flake8==7.1.1 \ --hash=sha256:049d058491e228e03e67b390f311bbf88fce2dbaa8fa673e7aea87b7198b8d38 \ --hash=sha256:597477df7860daa5aa0fdd84bf5208a043ab96b8e96ab708770ae0364dd03213 # via -r requirements.in importlib-metadata==8.4.0 \ --hash=sha256:66f342cc6ac9818fc6ff340576acd24d65ba0b3efabb2b4ac08b598965a4a2f1 \ --hash=sha256:9a547d3bc3608b025f93d403fdd1aae741c24fbb8314df4b155675742ce303c5 # via pytest-randomly iniconfig==2.0.0 \ --hash=sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3 \ --hash=sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374 # via pytest mccabe==0.7.0 \ --hash=sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325 \ --hash=sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e # via flake8 packaging==24.1 \ --hash=sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002 \ --hash=sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124 # via pytest pluggy==1.5.0 \ --hash=sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1 \ --hash=sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669 # via pytest pycodestyle==2.12.1 \ --hash=sha256:46f0fb92069a7c28ab7bb558f05bfc0110dac69a0cd23c61ea0040283a9d78b3 \ --hash=sha256:6838eae08bbce4f6accd5d5572075c63626a15ee3e6f842df996bf62f6d73521 # via flake8 pyflakes==3.2.0 \ --hash=sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f \ --hash=sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a # via flake8 pytest==8.3.2 \ --hash=sha256:4ba08f9ae7dcf84ded419494d229b48d0903ea6407b030eaec46df5e6a73bba5 \ --hash=sha256:c132345d12ce551242c87269de812483f5bcc87cdbb4722e48487ba194f9fdce # via # -r requirements.in # pytest-randomly pytest-randomly==3.15.0 \ --hash=sha256:0516f4344b29f4e9cdae8bce31c4aeebf59d0b9ef05927c33354ff3859eeeca6 \ --hash=sha256:b908529648667ba5e54723088edd6f82252f540cc340d748d1fa985539687047 # via -r requirements.in tomli==2.0.1 \ --hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \ --hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f # via pytest zipp==3.20.1 \ --hash=sha256:9960cd8967c8f85a56f920d5d507274e74f9ff813a0ab8889a5b5be2daf44064 \ --hash=sha256:c22b14cc4763c5a5b04134207736c107db42e9d3ef2d9779d465f5f1bcba572b # via importlib-metadata pytest-flake8-path-1.6.0/tests/requirements/requirements.in000066400000000000000000000000361470673317000241170ustar00rootroot00000000000000flake8 pytest pytest-randomly pytest-flake8-path-1.6.0/tests/test_pytest_flake8_path.py000066400000000000000000000065041470673317000235360ustar00rootroot00000000000000from __future__ import annotations import os from textwrap import dedent import flake8 from pytest_flake8_path import Flake8Result # Prevent Flake8 from running in dev mode because it returns some problems os.environ.pop("PYTHONDEVMODE", None) def test_windows_path_normalization(): result = Flake8Result( out=( ".\\example.py:1:2: E221 multiple spaces before operator\n" + "Flake8 is here!\n" ), err="", exit_code=0, ) assert result.out_lines == [ "./example.py:1:2: E221 multiple spaces before operator", "Flake8 is here!", ] def test_simple_run(flake8_path): (flake8_path / "example.py").write_text("x = 1\n") result = flake8_path.run_flake8() assert result.out_lines == [ "./example.py:1:2: E221 multiple spaces before operator" ] assert result.err_lines == [] assert result.exit_code == 1 def test_multi_line(flake8_path): (flake8_path / "example.py").write_text( dedent( """\ x = 1 y = 2 """ ) ) result = flake8_path.run_flake8() assert result.out_lines == [ "./example.py:1:2: E221 multiple spaces before operator", "./example.py:2:2: E221 multiple spaces before operator", ] assert result.err_lines == [] assert result.exit_code == 1 def test_with_setup_cfg(flake8_path): (flake8_path / "setup.cfg").write_text( dedent( """\ [flake8] ignore = E221 """ ) ) (flake8_path / "example.py").write_text("x = 1\n") result = flake8_path.run_flake8() assert result.out_lines == [] assert result.err_lines == [] assert result.exit_code == 0 def test_error_output(flake8_path): (flake8_path / "setup.cfg").write_text( dedent( """ [flake8] extend-select = MC1 [flake8:local-plugins] extension = MC1 = example:MyChecker1 paths = . """ ) ) (flake8_path / "example.py").write_text( dedent( """ import warnings warnings.warn("This is a warning!", UserWarning) class MyChecker1: name = "MyChecker1" version = "1" def __init__(self, tree): self.tree = tree def run(self): if False: yield """ ) ) result = flake8_path.run_flake8() assert "This is a warning!" in result.err assert result.err_lines[0].endswith("UserWarning: This is a warning!") assert result.err_lines[1] == ' warnings.warn("This is a warning!", UserWarning)' def test_extra_args(flake8_path): (flake8_path / "example.py").write_text("x = 1\n") result = flake8_path.run_flake8(["--ignore", "E221"]) assert result.out_lines == [] assert result.err_lines == [] assert result.exit_code == 0 def test_extra_args_version(flake8_path): result = flake8_path.run_flake8(extra_args=["--version"]) assert result.out.startswith(flake8.__version__ + " ") def test_separate_tmp_path(flake8_path, tmp_path): (flake8_path / "example.py").write_text("x = 1\n") assert not (tmp_path / "example.py").exists() pytest-flake8-path-1.6.0/tox.ini000066400000000000000000000006551470673317000165010ustar00rootroot00000000000000[tox] requires = tox>=4.2 env_list = py{313, 312, 311, 310, 39} [testenv] package = wheel wheel_build_env = .pkg deps = -r tests/requirements/{envname}.txt set_env = PYTHONDEVMODE = 1 commands = python \ -W error::ResourceWarning \ -W error::DeprecationWarning \ -W error::PendingDeprecationWarning \ -m pytest {posargs:tests} [flake8] max-line-length = 88 extend-ignore = E203,E501