pax_global_header00006660000000000000000000000064144530153100014506gustar00rootroot0000000000000052 comment=c5d2abaca929e7b64657ac0c4c9bc896a71874bf pytest-flake8-path-1.5.0/000077500000000000000000000000001445301531000151435ustar00rootroot00000000000000pytest-flake8-path-1.5.0/.editorconfig000066400000000000000000000003451445301531000176220ustar00rootroot00000000000000# 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.5.0/.github/000077500000000000000000000000001445301531000165035ustar00rootroot00000000000000pytest-flake8-path-1.5.0/.github/CODE_OF_CONDUCT.md000066400000000000000000000001311445301531000212750ustar00rootroot00000000000000This project follows [Django's Code of Conduct](https://www.djangoproject.com/conduct/). pytest-flake8-path-1.5.0/.github/ISSUE_TEMPLATE/000077500000000000000000000000001445301531000206665ustar00rootroot00000000000000pytest-flake8-path-1.5.0/.github/ISSUE_TEMPLATE/config.yml000066400000000000000000000000341445301531000226530ustar00rootroot00000000000000blank_issues_enabled: false pytest-flake8-path-1.5.0/.github/ISSUE_TEMPLATE/feature-request.yml000066400000000000000000000004111445301531000245260ustar00rootroot00000000000000name: 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.5.0/.github/ISSUE_TEMPLATE/issue.yml000066400000000000000000000015261445301531000225450ustar00rootroot00000000000000name: 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.5.0/.github/SECURITY.md000066400000000000000000000001011445301531000202640ustar00rootroot00000000000000Please report security issues directly over email to me@adamj.eu pytest-flake8-path-1.5.0/.github/dependabot.yml000066400000000000000000000001521445301531000213310ustar00rootroot00000000000000version: 2 updates: - package-ecosystem: github-actions directory: "/" schedule: interval: weekly pytest-flake8-path-1.5.0/.github/workflows/000077500000000000000000000000001445301531000205405ustar00rootroot00000000000000pytest-flake8-path-1.5.0/.github/workflows/main.yml000066400000000000000000000016271445301531000222150ustar00rootroot00000000000000name: CI on: push: branches: - main pull_request: concurrency: group: ${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: tests: name: Python ${{ matrix.python-version }} runs-on: ubuntu-22.04 strategy: matrix: python-version: - 3.8 - 3.9 - '3.10' - '3.11' - '3.12' steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} allow-prereleases: true cache: pip cache-dependency-path: 'requirements/*.txt' - name: Install dependencies run: | python -m pip install --upgrade pip setuptools wheel python -m pip install --upgrade 'tox>=4.0.0rc3' - name: Run tox targets for ${{ matrix.python-version }} run: tox run -f py$(echo ${{ matrix.python-version }} | tr -d .) pytest-flake8-path-1.5.0/.gitignore000066400000000000000000000000771445301531000171370ustar00rootroot00000000000000*.egg-info/ *.pyc /.coverage /.coverage.* /.tox /build/ /dist/ pytest-flake8-path-1.5.0/.pre-commit-config.yaml000066400000000000000000000033401445301531000214240ustar00rootroot00000000000000default_language_version: python: python3.11 repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.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: 0.12.1 hooks: - id: pyproject-fmt - repo: https://github.com/asottile/setup-cfg-fmt rev: v2.4.0 hooks: - id: setup-cfg-fmt args: - --include-version-classifiers - --max-py-version - '3.12' - repo: https://github.com/tox-dev/tox-ini-fmt rev: 1.3.1 hooks: - id: tox-ini-fmt - repo: https://github.com/rstcheck/rstcheck rev: v6.1.2 hooks: - id: rstcheck additional_dependencies: - tomli==2.0.1 - repo: https://github.com/asottile/pyupgrade rev: v3.8.0 hooks: - id: pyupgrade args: [--py38-plus] - repo: https://github.com/psf/black rev: 23.3.0 hooks: - id: black - repo: https://github.com/adamchainz/blacken-docs rev: 1.14.0 hooks: - id: blacken-docs additional_dependencies: - black==23.1.0 - repo: https://github.com/asottile/reorder-python-imports rev: v3.10.0 hooks: - id: reorder-python-imports args: - --py38-plus - --application-directories - .:example:src - --add-import - 'from __future__ import annotations' - repo: https://github.com/PyCQA/flake8 rev: 6.0.0 hooks: - id: flake8 additional_dependencies: - flake8-bugbear - flake8-comprehensions - flake8-tidy-imports - flake8-typing-imports - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.4.1 hooks: - id: mypy additional_dependencies: - pytest==7.1.2 pytest-flake8-path-1.5.0/CHANGELOG.rst000066400000000000000000000012731445301531000171670ustar00rootroot00000000000000========= Changelog ========= 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.5.0/HISTORY.rst000066400000000000000000000001151445301531000170330ustar00rootroot00000000000000See https://github.com/adamchainz/pytest-flake8-path/blob/main/CHANGELOG.rst pytest-flake8-path-1.5.0/LICENSE000066400000000000000000000020551445301531000161520ustar00rootroot00000000000000MIT 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.5.0/MANIFEST.in000066400000000000000000000001631445301531000167010ustar00rootroot00000000000000prune tests include CHANGELOG.rst include LICENSE include pyproject.toml include README.rst include src/*/py.typed pytest-flake8-path-1.5.0/README.rst000066400000000000000000000140711445301531000166350ustar00rootroot00000000000000================== pytest-flake8-path ================== .. image:: https://img.shields.io/github/actions/workflow/status/adamchainz/pytest-flake8-path/main.yml?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" ] Installation ============ Use **pip**: .. code-block:: sh python -m pip install pytest-flake8-path Python 3.8 to 3.12 supported. ---- **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. ---- 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.5.0/pyproject.toml000066400000000000000000000007001445301531000200540ustar00rootroot00000000000000[build-system] build-backend = "setuptools.build_meta" requires = [ "setuptools", ] [tool.black] target-version = ['py38'] [tool.pytest.ini_options] addopts = """\ --strict-config --strict-markers """ [tool.mypy] mypy_path = "src/" namespace_packages = false show_error_codes = true strict = true warn_unreachable = true [[tool.mypy.overrides]] module = "tests.*" allow_untyped_defs = true [tool.rstcheck] report_level = "ERROR" pytest-flake8-path-1.5.0/requirements/000077500000000000000000000000001445301531000176665ustar00rootroot00000000000000pytest-flake8-path-1.5.0/requirements/compile.py000077500000000000000000000021231445301531000216710ustar00rootroot00000000000000#!/usr/bin/env python from __future__ import annotations import os import subprocess import sys from pathlib import Path if __name__ == "__main__": os.chdir(Path(__file__).parent) os.environ["CUSTOM_COMPILE_COMMAND"] = "requirements/compile.py" os.environ["PIP_REQUIRE_VIRTUALENV"] = "0" common_args = [ "-m", "piptools", "compile", "--generate-hashes", "--allow-unsafe", ] + sys.argv[1:] subprocess.run( ["python3.8", *common_args, "-o", "py38.txt"], check=True, capture_output=True, ) subprocess.run( ["python3.9", *common_args, "-o", "py39.txt"], check=True, capture_output=True, ) subprocess.run( ["python3.10", *common_args, "-o", "py310.txt"], check=True, capture_output=True, ) subprocess.run( ["python3.11", *common_args, "-o", "py311.txt"], check=True, capture_output=True, ) subprocess.run( ["python3.12", *common_args, "-o", "py312.txt"], check=True, capture_output=True, ) pytest-flake8-path-1.5.0/requirements/py310.txt000066400000000000000000000046011445301531000213040ustar00rootroot00000000000000# # This file is autogenerated by pip-compile with Python 3.10 # by the following command: # # requirements/compile.py # exceptiongroup==1.1.1 \ --hash=sha256:232c37c63e4f682982c8b6459f33a8981039e5fb8756b2074364e5055c498c9e \ --hash=sha256:d484c3090ba2889ae2928419117447a14daf3c1231d5e30d0aae34f354f01785 # via pytest flake8==6.0.0 \ --hash=sha256:3833794e27ff64ea4e9cf5d410082a8b97ff1a06c16aa3d2027339cd0f1195c7 \ --hash=sha256:c61007e76655af75e6785a931f452915b371dc48f56efd765247c8fe68f2b181 # 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==23.1 \ --hash=sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61 \ --hash=sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f # via pytest pluggy==1.0.0 \ --hash=sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159 \ --hash=sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3 # via pytest pycodestyle==2.10.0 \ --hash=sha256:347187bdb476329d98f695c213d7295a846d1152ff4fe9bacb8a9590b8ee7053 \ --hash=sha256:8a4eaf0d0495c7395bdab3589ac2db602797d76207242c17d470186815706610 # via flake8 pyflakes==3.0.1 \ --hash=sha256:ec55bf7fe21fff7f1ad2f7da62363d749e2a470500eab1b555334b67aa1ef8cf \ --hash=sha256:ec8b276a6b60bd80defed25add7e439881c19e64850afd9b346283d4165fd0fd # via flake8 pytest==7.3.2 \ --hash=sha256:cdcbd012c9312258922f8cd3f1b62a6580fdced17db6014896053d47cddf9295 \ --hash=sha256:ee990a3cc55ba808b80795a79944756f315c67c12b56abd3ac993a7b8c17030b # via # -r requirements.in # pytest-randomly pytest-randomly==3.12.0 \ --hash=sha256:d60c2db71ac319aee0fc6c4110a7597d611a8b94a5590918bfa8583f00caccb2 \ --hash=sha256:f4f2e803daf5d1ba036cc22bf4fe9dbbf99389ec56b00e5cba732fb5c1d07fdd # via -r requirements.in tomli==2.0.1 \ --hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \ --hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f # via pytest pytest-flake8-path-1.5.0/requirements/py311.txt000066400000000000000000000037501445301531000213110ustar00rootroot00000000000000# # This file is autogenerated by pip-compile with Python 3.11 # by the following command: # # requirements/compile.py # flake8==6.0.0 \ --hash=sha256:3833794e27ff64ea4e9cf5d410082a8b97ff1a06c16aa3d2027339cd0f1195c7 \ --hash=sha256:c61007e76655af75e6785a931f452915b371dc48f56efd765247c8fe68f2b181 # 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==23.1 \ --hash=sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61 \ --hash=sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f # via pytest pluggy==1.0.0 \ --hash=sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159 \ --hash=sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3 # via pytest pycodestyle==2.10.0 \ --hash=sha256:347187bdb476329d98f695c213d7295a846d1152ff4fe9bacb8a9590b8ee7053 \ --hash=sha256:8a4eaf0d0495c7395bdab3589ac2db602797d76207242c17d470186815706610 # via flake8 pyflakes==3.0.1 \ --hash=sha256:ec55bf7fe21fff7f1ad2f7da62363d749e2a470500eab1b555334b67aa1ef8cf \ --hash=sha256:ec8b276a6b60bd80defed25add7e439881c19e64850afd9b346283d4165fd0fd # via flake8 pytest==7.3.2 \ --hash=sha256:cdcbd012c9312258922f8cd3f1b62a6580fdced17db6014896053d47cddf9295 \ --hash=sha256:ee990a3cc55ba808b80795a79944756f315c67c12b56abd3ac993a7b8c17030b # via # -r requirements.in # pytest-randomly pytest-randomly==3.12.0 \ --hash=sha256:d60c2db71ac319aee0fc6c4110a7597d611a8b94a5590918bfa8583f00caccb2 \ --hash=sha256:f4f2e803daf5d1ba036cc22bf4fe9dbbf99389ec56b00e5cba732fb5c1d07fdd # via -r requirements.in pytest-flake8-path-1.5.0/requirements/py312.txt000066400000000000000000000037501445301531000213120ustar00rootroot00000000000000# # This file is autogenerated by pip-compile with Python 3.12 # by the following command: # # requirements/compile.py # flake8==6.0.0 \ --hash=sha256:3833794e27ff64ea4e9cf5d410082a8b97ff1a06c16aa3d2027339cd0f1195c7 \ --hash=sha256:c61007e76655af75e6785a931f452915b371dc48f56efd765247c8fe68f2b181 # 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==23.1 \ --hash=sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61 \ --hash=sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f # via pytest pluggy==1.0.0 \ --hash=sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159 \ --hash=sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3 # via pytest pycodestyle==2.10.0 \ --hash=sha256:347187bdb476329d98f695c213d7295a846d1152ff4fe9bacb8a9590b8ee7053 \ --hash=sha256:8a4eaf0d0495c7395bdab3589ac2db602797d76207242c17d470186815706610 # via flake8 pyflakes==3.0.1 \ --hash=sha256:ec55bf7fe21fff7f1ad2f7da62363d749e2a470500eab1b555334b67aa1ef8cf \ --hash=sha256:ec8b276a6b60bd80defed25add7e439881c19e64850afd9b346283d4165fd0fd # via flake8 pytest==7.3.2 \ --hash=sha256:cdcbd012c9312258922f8cd3f1b62a6580fdced17db6014896053d47cddf9295 \ --hash=sha256:ee990a3cc55ba808b80795a79944756f315c67c12b56abd3ac993a7b8c17030b # via # -r requirements.in # pytest-randomly pytest-randomly==3.12.0 \ --hash=sha256:d60c2db71ac319aee0fc6c4110a7597d611a8b94a5590918bfa8583f00caccb2 \ --hash=sha256:f4f2e803daf5d1ba036cc22bf4fe9dbbf99389ec56b00e5cba732fb5c1d07fdd # via -r requirements.in pytest-flake8-path-1.5.0/requirements/py38.txt000066400000000000000000000054621445301531000212410ustar00rootroot00000000000000# # This file is autogenerated by pip-compile with Python 3.8 # by the following command: # # requirements/compile.py # exceptiongroup==1.1.1 \ --hash=sha256:232c37c63e4f682982c8b6459f33a8981039e5fb8756b2074364e5055c498c9e \ --hash=sha256:d484c3090ba2889ae2928419117447a14daf3c1231d5e30d0aae34f354f01785 # via pytest flake8==6.0.0 \ --hash=sha256:3833794e27ff64ea4e9cf5d410082a8b97ff1a06c16aa3d2027339cd0f1195c7 \ --hash=sha256:c61007e76655af75e6785a931f452915b371dc48f56efd765247c8fe68f2b181 # via -r requirements.in importlib-metadata==6.6.0 \ --hash=sha256:43dd286a2cd8995d5eaef7fee2066340423b818ed3fd70adf0bad5f1fac53fed \ --hash=sha256:92501cdf9cc66ebd3e612f1b4f0c0765dfa42f0fa38ffb319b6bd84dd675d705 # 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==23.1 \ --hash=sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61 \ --hash=sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f # via pytest pluggy==1.0.0 \ --hash=sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159 \ --hash=sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3 # via pytest pycodestyle==2.10.0 \ --hash=sha256:347187bdb476329d98f695c213d7295a846d1152ff4fe9bacb8a9590b8ee7053 \ --hash=sha256:8a4eaf0d0495c7395bdab3589ac2db602797d76207242c17d470186815706610 # via flake8 pyflakes==3.0.1 \ --hash=sha256:ec55bf7fe21fff7f1ad2f7da62363d749e2a470500eab1b555334b67aa1ef8cf \ --hash=sha256:ec8b276a6b60bd80defed25add7e439881c19e64850afd9b346283d4165fd0fd # via flake8 pytest==7.3.2 \ --hash=sha256:cdcbd012c9312258922f8cd3f1b62a6580fdced17db6014896053d47cddf9295 \ --hash=sha256:ee990a3cc55ba808b80795a79944756f315c67c12b56abd3ac993a7b8c17030b # via # -r requirements.in # pytest-randomly pytest-randomly==3.12.0 \ --hash=sha256:d60c2db71ac319aee0fc6c4110a7597d611a8b94a5590918bfa8583f00caccb2 \ --hash=sha256:f4f2e803daf5d1ba036cc22bf4fe9dbbf99389ec56b00e5cba732fb5c1d07fdd # via -r requirements.in tomli==2.0.1 \ --hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \ --hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f # via pytest zipp==3.15.0 \ --hash=sha256:112929ad649da941c23de50f356a2b5570c954b65150642bccdd66bf194d224b \ --hash=sha256:48904fc76a60e542af151aded95726c1a5c34ed43ab4134b597665c86d7ad556 # via importlib-metadata pytest-flake8-path-1.5.0/requirements/py39.txt000066400000000000000000000054621445301531000212420ustar00rootroot00000000000000# # This file is autogenerated by pip-compile with Python 3.9 # by the following command: # # requirements/compile.py # exceptiongroup==1.1.1 \ --hash=sha256:232c37c63e4f682982c8b6459f33a8981039e5fb8756b2074364e5055c498c9e \ --hash=sha256:d484c3090ba2889ae2928419117447a14daf3c1231d5e30d0aae34f354f01785 # via pytest flake8==6.0.0 \ --hash=sha256:3833794e27ff64ea4e9cf5d410082a8b97ff1a06c16aa3d2027339cd0f1195c7 \ --hash=sha256:c61007e76655af75e6785a931f452915b371dc48f56efd765247c8fe68f2b181 # via -r requirements.in importlib-metadata==6.6.0 \ --hash=sha256:43dd286a2cd8995d5eaef7fee2066340423b818ed3fd70adf0bad5f1fac53fed \ --hash=sha256:92501cdf9cc66ebd3e612f1b4f0c0765dfa42f0fa38ffb319b6bd84dd675d705 # 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==23.1 \ --hash=sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61 \ --hash=sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f # via pytest pluggy==1.0.0 \ --hash=sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159 \ --hash=sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3 # via pytest pycodestyle==2.10.0 \ --hash=sha256:347187bdb476329d98f695c213d7295a846d1152ff4fe9bacb8a9590b8ee7053 \ --hash=sha256:8a4eaf0d0495c7395bdab3589ac2db602797d76207242c17d470186815706610 # via flake8 pyflakes==3.0.1 \ --hash=sha256:ec55bf7fe21fff7f1ad2f7da62363d749e2a470500eab1b555334b67aa1ef8cf \ --hash=sha256:ec8b276a6b60bd80defed25add7e439881c19e64850afd9b346283d4165fd0fd # via flake8 pytest==7.3.2 \ --hash=sha256:cdcbd012c9312258922f8cd3f1b62a6580fdced17db6014896053d47cddf9295 \ --hash=sha256:ee990a3cc55ba808b80795a79944756f315c67c12b56abd3ac993a7b8c17030b # via # -r requirements.in # pytest-randomly pytest-randomly==3.12.0 \ --hash=sha256:d60c2db71ac319aee0fc6c4110a7597d611a8b94a5590918bfa8583f00caccb2 \ --hash=sha256:f4f2e803daf5d1ba036cc22bf4fe9dbbf99389ec56b00e5cba732fb5c1d07fdd # via -r requirements.in tomli==2.0.1 \ --hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \ --hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f # via pytest zipp==3.15.0 \ --hash=sha256:112929ad649da941c23de50f356a2b5570c954b65150642bccdd66bf194d224b \ --hash=sha256:48904fc76a60e542af151aded95726c1a5c34ed43ab4134b597665c86d7ad556 # via importlib-metadata pytest-flake8-path-1.5.0/requirements/requirements.in000066400000000000000000000000361445301531000227400ustar00rootroot00000000000000flake8 pytest pytest-randomly pytest-flake8-path-1.5.0/setup.cfg000066400000000000000000000026341445301531000167710ustar00rootroot00000000000000[metadata] name = pytest_flake8_path version = 1.5.0 description = A pytest fixture for testing flake8 plugins. long_description = file: README.rst long_description_content_type = text/x-rst url = https://github.com/adamchainz/pytest-flake8-path author = Adam Johnson author_email = me@adamj.eu license = MIT license_files = LICENSE 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 Programming Language :: Python :: 3 :: Only Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 Programming Language :: Python :: 3.12 Typing :: Typed keywords = pytest, flake8 project_urls = Changelog = https://github.com/adamchainz/pytest-flake8-path/blob/main/CHANGELOG.rst Mastodon = https://fosstodon.org/@adamchainz Twitter = https://twitter.com/adamchainz [options] packages = find: install_requires = flake8 pytest python_requires = >=3.8 include_package_data = True package_dir = =src zip_safe = False [options.packages.find] where = src [options.entry_points] pytest11 = flake8_path = pytest_flake8_path [flake8] max-line-length = 88 extend-ignore = E203 pytest-flake8-path-1.5.0/src/000077500000000000000000000000001445301531000157325ustar00rootroot00000000000000pytest-flake8-path-1.5.0/src/pytest_flake8_path/000077500000000000000000000000001445301531000215305ustar00rootroot00000000000000pytest-flake8-path-1.5.0/src/pytest_flake8_path/__init__.py000066400000000000000000000034571445301531000236520ustar00rootroot00000000000000from __future__ import annotations import subprocess import sys from pathlib import Path from typing import Generator 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, None, None]: path = Flake8Path(tmp_path_factory.mktemp("flake8_path")) (path / "setup.cfg").write_text("[flake8]\n") yield path pytest-flake8-path-1.5.0/src/pytest_flake8_path/py.typed000066400000000000000000000000001445301531000232150ustar00rootroot00000000000000pytest-flake8-path-1.5.0/tests/000077500000000000000000000000001445301531000163055ustar00rootroot00000000000000pytest-flake8-path-1.5.0/tests/__init__.py000066400000000000000000000000001445301531000204040ustar00rootroot00000000000000pytest-flake8-path-1.5.0/tests/test_pytest_flake8_path.py000066400000000000000000000065041445301531000235210ustar00rootroot00000000000000from __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.5.0/tox.ini000066400000000000000000000005261445301531000164610ustar00rootroot00000000000000[tox] requires = tox>=4.2 env_list = py{312, 311, 310, 39, 38} [testenv] package = wheel deps = -r requirements/{envname}.txt set_env = PYTHONDEVMODE = 1 commands = python \ -W error::ResourceWarning \ -W error::DeprecationWarning \ -W error::PendingDeprecationWarning \ -m pytest {posargs:tests}