pytest-click-1.1.0/0000755000175000017500000000000014201423467013453 5ustar jeromejeromepytest-click-1.1.0/pyproject.toml0000644000175000017500000000056514201423467016375 0ustar jeromejerome[build-system] requires = ["setuptools >= 40.6.0", "wheel"] build-backend = "setuptools.build_meta" [tool.black] line-length = 120 target_version = ["py38"] [tool.isort] line_length = 120 multi_line_output = 3 default_section = "THIRDPARTY" include_trailing_comma = true known_first_party = "pytest_click" known_third_party = ["_pytest", "click", "pytest", "setuptools"] pytest-click-1.1.0/src/0000755000175000017500000000000014201423467014242 5ustar jeromejeromepytest-click-1.1.0/src/pytest_click/0000755000175000017500000000000014201423467016737 5ustar jeromejeromepytest-click-1.1.0/src/pytest_click/__init__.py0000644000175000017500000000043314201423467021050 0ustar jeromejeromefrom _pytest.config import Config from .fixtures import cli_runner, isolated_cli_runner def pytest_configure(config: Config) -> None: config.addinivalue_line( "markers", "runner_setup(**kwargs): Pass kwargs to `click.testing.CliRunner` initialization.", ) pytest-click-1.1.0/src/pytest_click/fixtures.py0000644000175000017500000000154414201423467021166 0ustar jeromejerome# pylint: disable=redefined-outer-name from typing import Generator import pytest from _pytest.fixtures import SubRequest from click.testing import CliRunner @pytest.fixture def cli_runner(request: SubRequest) -> CliRunner: """Instance of `click.testing.CliRunner`. Can be configured with `@pytest.mark.runner_setup`. @pytest.mark.runner_setup(charset="cp1251") def test_something(cli_runner): ... """ init_kwargs = {} marker = request.node.get_closest_marker("runner_setup") if marker: init_kwargs = marker.kwargs return CliRunner(**init_kwargs) @pytest.fixture def isolated_cli_runner(cli_runner: CliRunner) -> Generator[CliRunner, None, None]: """Instance of `click.testing.CliRunner` with automagically `isolated_filesystem()` called.""" with cli_runner.isolated_filesystem(): yield cli_runner pytest-click-1.1.0/.yamllint0000644000175000017500000000006414201423467015305 0ustar jeromejeromeextends: relaxed rules: line-length: max: 120 pytest-click-1.1.0/LICENSE0000644000175000017500000000207514201423467014464 0ustar jeromejeromeThe MIT License (MIT) Copyright (c) 2016-2020 Dmitry Dygalo 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-click-1.1.0/mypy.ini0000644000175000017500000000052314201423467015152 0ustar jeromejerome[mypy] python_version = 3.8 show_error_context = true verbosity = 0 ignore_missing_imports = true show_traceback = true check_untyped_defs = true cache_fine_grained = true strict_equality = true no_implicit_optional = true warn_unreachable = true disallow_untyped_calls = true disallow_untyped_defs = true disallow_incomplete_defs = true pytest-click-1.1.0/.github/0000755000175000017500000000000014201423467015013 5ustar jeromejeromepytest-click-1.1.0/.github/workflows/0000755000175000017500000000000014201423467017050 5ustar jeromejeromepytest-click-1.1.0/.github/workflows/release.yml0000644000175000017500000000170614201423467021217 0ustar jeromejeromename: Post-release jobs on: release: types: [published] jobs: build-n-publish: name: Build and publish Python 🐍distributions 📦 to PyPI runs-on: ubuntu-20.04 steps: - uses: actions/checkout@master - name: Set up Python 3.8 uses: actions/setup-python@v1 with: python-version: 3.8 - name: Install tox run: >- python -m pip install tox --user - name: Build a binary wheel and a source tarball run: >- python -m tox -e build - name: Publish distribution 📦 to PyPI uses: pypa/gh-action-pypi-publish@master with: password: ${{ secrets.PYPI_TOKEN }} release-notes: name: Release Notes runs-on: ubuntu-latest steps: - name: Check out code uses: actions/checkout@v1 - name: Release Notary Action uses: docker://outillage/release-notary env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} pytest-click-1.1.0/.github/workflows/build.yml0000644000175000017500000000423314201423467020674 0ustar jeromejeromename: build # Triggered by changes in code-specific or job-specific files on: pull_request: paths: - '**.py' - '.github/workflows/*.yml' - '.pylintrc' - '.pre-commit-config.yaml' - '.pydocstyle' - '.relint.yml' - 'mypy.ini' - '.yamllint' - 'tox.ini' push: branches: - master jobs: pre-commit: name: Generic pre-commit checks runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: fetch-depth: 1 - uses: actions/setup-python@v2 with: python-version: 3.8 - run: pip install pre-commit - run: SKIP=pylint pre-commit run --all-files pylint: name: Pylint runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: fetch-depth: 1 - uses: actions/setup-python@v2 with: python-version: 3.8 - run: pip install pre-commit - run: pre-commit run pylint --all-files mypy: name: Mypy runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 with: fetch-depth: 1 - uses: actions/setup-python@v1 with: python-version: 3.8 - run: pip install pre-commit - run: pre-commit run mypy --all-files tests: strategy: matrix: os: [ubuntu-latest, windows-latest] python: ['3.7', '3.8', '3.9', '3.10', 'pypy3'] name: ${{ matrix.os }}/tests_${{ matrix.python }} runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 with: fetch-depth: 1 - uses: actions/setup-python@v2 with: python-version: ${{ matrix.python }} - run: pip install tox coverage - name: Run ${{ matrix.python }} tox job run: tox -e py env: TOX_JOB: ${{ matrix.python }} - run: coverage combine - run: coverage report - run: coverage xml -i - name: Upload coverage to Codecov uses: codecov/codecov-action@v1.0.7 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.xml flags: unittests name: codecov-py${{ matrix.python }} pytest-click-1.1.0/.github/workflows/commit.yml0000644000175000017500000000047414201423467021070 0ustar jeromejeromename: Checks for every commit on: pull_request: ~ push: branches: - master jobs: commitsar: name: Verify commit messages runs-on: ubuntu-latest steps: - name: Check out code uses: actions/checkout@v1 - name: Run commitsar uses: docker://commitsar/commitsar pytest-click-1.1.0/.github/FUNDING.yml0000644000175000017500000000002514201423467016625 0ustar jeromejeromegithub: Stranger6667 pytest-click-1.1.0/.coveragerc0000644000175000017500000000045714201423467015602 0ustar jeromejerome[run] branch = true parallel = true source = pytest_click [paths] source = src/pytest_click .tox/*/lib/python*/site-packages/pytest_click [report] show_missing = true precision = 2 exclude_lines = raise NotImplementedError omit = */tests/* setup.py */*.egg/* */*.egg-info/* pytest-click-1.1.0/CODE_OF_CONDUCT.md0000644000175000017500000000642614201423467016262 0ustar jeromejerome# Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at dadygalo@gmail.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq pytest-click-1.1.0/MANIFEST.in0000644000175000017500000000017714201423467015216 0ustar jeromejeromeinclude CHANGELOG.md include README.rst recursive-include test * recursive-exclude * __pycache__ recursive-exclude * *.py[co] pytest-click-1.1.0/.pylintrc0000644000175000017500000000100014201423467015307 0ustar jeromejerome[MASTER] # jobs=0 means 'use all CPUs' jobs=0 [MESSAGES CONTROL] disable = missing-docstring, line-too-long, invalid-name, no-value-for-parameter, no-member, unused-argument, broad-except, relative-import, wrong-import-position, bare-except, locally-disabled, protected-access, abstract-method, no-self-use, fixme, too-few-public-methods, bad-continuation, inconsistent-return-statements [REPORTS] output-format=colorized [FORMAT] logging-modules= logging, structlog, pytest-click-1.1.0/tox.ini0000644000175000017500000000123014201423467014762 0ustar jeromejerome[tox] isolated_build = true envlist = py{37,38,39,310,py3}, coverage-report [testenv] setenv = PYTHONPATH = {toxinidir}:{toxinidir}/pytest_click LC_ALL=en_US.utf-8 LANG=en_US.utf-8 deps = pytest coverage click commands = coverage run --source=pytest_click -m pytest {posargs:test} [testenv:coverage-report] description = Report coverage over all measured test runs. basepython = python3.8 deps = coverage skip_install = true depends = py{37,38,39,310} commands = coverage combine coverage report coverage xml -i {posargs:} [testenv:build] deps = pep517 commands = python -m pep517.build --source . --binary --out-dir dist/ pytest-click-1.1.0/.gitignore0000644000175000017500000000056014201423467015444 0ustar jeromejerome*.py[cod] # C extensions *.so # Packages *.egg *.egg-info .eggs dist build eggs parts bin var sdist develop-eggs .installed.cfg lib lib64 venv*/ pyvenv*/ # Installer logs pip-log.txt # Unit test / coverage reports .coverage coverage.xml junit.xml .tox .coverage.* htmlcov # Translations *.mo .idea .DS_Store *~ .*.sw[po] .build .ve .env .bootstrap *.bak .cache pytest-click-1.1.0/test/0000755000175000017500000000000014201423467014432 5ustar jeromejeromepytest-click-1.1.0/test/fixtures/0000755000175000017500000000000014201423467016303 5ustar jeromejeromepytest-click-1.1.0/test/fixtures/__init__.py0000644000175000017500000000000014201423467020402 0ustar jeromejeromepytest-click-1.1.0/test/fixtures/test_cli_runner.py0000644000175000017500000000303214201423467022052 0ustar jeromejeromedef test_fixture(testdir): testdir.makepyfile( """ from click.testing import CliRunner def test_fixture(cli_runner): assert isinstance(cli_runner, CliRunner) """ ) result = testdir.runpytest("--verbose") result.stdout.fnmatch_lines("test_fixture.py::test_fixture PASSED*") def test_real_invocation(testdir): testdir.makepyfile( """ import click def test_fixture(cli_runner): @click.command() @click.argument('name') def hello(name): click.echo('Hello %s!' % name) result = cli_runner.invoke(hello, ['Peter']) assert result.exit_code == 0 assert result.output == 'Hello Peter!\\n' """ ) result = testdir.runpytest("--verbose") result.stdout.fnmatch_lines("test_real_invocation.py::test_fixture PASSED*") def test_runner_setup(testdir): testdir.makepyfile( """ import pytest @pytest.mark.runner_setup(charset='cp1251', env={'test': 1}, echo_stdin=True) def test_runner_setup(cli_runner): assert cli_runner.charset == 'cp1251' assert cli_runner.env == {'test': 1} assert cli_runner.echo_stdin """ ) result = testdir.runpytest("--verbose") result.stdout.fnmatch_lines("test_runner_setup.py::test_runner_setup PASSED*") def test_docstring(testdir): result = testdir.runpytest("--fixtures") assert ( " Instance of `click.testing.CliRunner`. Can be " "configured with `@pytest.mark.runner_setup`." in result.stdout.lines ) pytest-click-1.1.0/test/fixtures/test_isolated_cli_runner.py0000644000175000017500000000316014201423467023740 0ustar jeromejeromedef test_fixture(testdir): testdir.makeconftest( """ try: from mock import patch, Mock except ImportError: from unittest.mock import patch, Mock def pytest_configure(config): config.patched = patch('pytest_click.fixtures.CliRunner.isolated_filesystem') config.patched.start() def pytest_unconfigure(config): config.patched.stop() """ ) testdir.makepyfile( """ from click.testing import CliRunner def test_fixture(isolated_cli_runner): assert isinstance(isolated_cli_runner, CliRunner) assert isolated_cli_runner.isolated_filesystem.called """ ) result = testdir.runpytest("--verbose") result.stdout.fnmatch_lines("test_fixture.py::test_fixture PASSED*") def test_real_invocation(testdir): testdir.makepyfile( """ import click def test_fixture(isolated_cli_runner): @click.command() @click.argument('f', type=click.File()) def cat(f): click.echo(f.read()) with open('hello.txt', 'w') as f: f.write('Hello World!') result = isolated_cli_runner.invoke(cat, ['hello.txt']) assert result.exit_code == 0 assert result.output == 'Hello World!\\n' """ ) result = testdir.runpytest("--verbose") result.stdout.fnmatch_lines("test_real_invocation.py::test_fixture PASSED*") def test_docstring(testdir): result = testdir.runpytest("--fixtures") assert ( " Instance of `click.testing.CliRunner` with " "automagically `isolated_filesystem()` called." in result.stdout.lines ) pytest-click-1.1.0/test/__init__.py0000644000175000017500000000000014201423467016531 0ustar jeromejeromepytest-click-1.1.0/test/test_plugin.py0000644000175000017500000000034414201423467017342 0ustar jeromejeromedef test_markers(testdir): result = testdir.runpytest("--markers") assert ( "@pytest.mark.runner_setup(**kwargs): " "Pass kwargs to `click.testing.CliRunner` initialization." in result.stdout.lines ) pytest-click-1.1.0/test/conftest.py0000644000175000017500000000003414201423467016626 0ustar jeromejeromepytest_plugins = "pytester" pytest-click-1.1.0/.pydocstyle0000644000175000017500000000027714201423467015661 0ustar jeromejerome[pydocstyle] # D100-D107 ignore missing docstrings # D203 disabled in favor of D211 # D213 disabled in favor of D212 ignore = D100,D101,D102,D103,D104,D105,D106,D107,D202,D203,D213,D401,D407 pytest-click-1.1.0/README.rst0000644000175000017500000000417214201423467015146 0ustar jeromejeromepytest-click ============ |Build| |Coverage| |Version| |Python versions| |License| `pytest `_ plugin for `Click `_. Installation ------------ The current stable release: :: pip install pytest_click Usage ----- ```pytest-click`` comes with some configurable fixtures - ``cli_runner`` and ``isolated_cli_runner``. .. code:: python import click def test_cli(cli_runner): @click.command() @click.argument("name") def hello(name): click.echo("Hello %s!" % name) result = cli_runner.invoke(hello, ["Peter"]) assert result.exit_code == 0 assert result.output == "Hello Peter!\n" .. code:: python import click def test_fixture(isolated_cli_runner): @click.command() @click.argument("f", type=click.File()) def cat(f): click.echo(f.read()) with open("hello.txt", "w") as f: f.write("Hello World!") result = isolated_cli_runner.invoke(cat, ["hello.txt"]) assert result.exit_code == 0 assert result.output == "Hello World!\n" Both runners can be configured via ``runner_setup`` mark: .. code:: python import pytest @pytest.mark.runner_setup(charset="cp1251", env={"test": 1}, echo_stdin=True) def test_runner_setup(cli_runner): ... All kwargs will be passed to ``click.testing.CliRunner`` initialization. .. |Build| image:: https://github.com/Stranger6667/pytest-click/workflows/build/badge.svg :target: https://github.com/Stranger6667/pytest-click/actions .. |Coverage| image:: https://codecov.io/github/Stranger6667/pytest-click/coverage.svg?branch=master :target: https://codecov.io/github/Stranger6667/pytest-click?branch=master .. |Version| image:: https://img.shields.io/pypi/v/pytest-click.svg :target: https://pypi.org/project/pytest-click/ .. |Python versions| image:: https://img.shields.io/pypi/pyversions/pytest-click.svg :target: https://pypi.org/project/pytest-click/ .. |License| image:: https://img.shields.io/pypi/l/pytest-click.svg :target: https://opensource.org/licenses/MIT pytest-click-1.1.0/.relint.yml0000644000175000017500000000037014201423467015551 0ustar jeromejerome- name: Fix it now pattern: "[fF][iI][xX][mM][eE]" filePattern: ".*.py$" - name: IPython debug leftover pattern: "IPython\\.embed()" filePattern: ".*.py$" - name: Leftover print pattern: "print\\(" filePattern: ^(?!.*conftest).*\.py$ pytest-click-1.1.0/.pre-commit-config.yaml0000644000175000017500000000314014201423467017732 0ustar jeromejeromedefault_language_version: python: python3.8 repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.1.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace exclude: ^.*\.(md|rst)$ - id: debug-statements - id: mixed-line-ending args: [--fix=lf] - id: check-merge-conflict - repo: https://github.com/jorisroovers/gitlint rev: v0.17.0 hooks: - id: gitlint - repo: https://github.com/adrienverge/yamllint rev: v1.26.3 hooks: - id: yamllint - repo: https://github.com/PyCQA/pydocstyle rev: 6.1.1 hooks: - id: pydocstyle - repo: https://github.com/codingjoe/relint rev: 1.2.1 hooks: - id: relint - repo: https://github.com/ambv/black rev: 22.1.0 hooks: - id: black types: [python] - repo: https://github.com/asottile/seed-isort-config rev: v2.2.0 hooks: - id: seed-isort-config - repo: https://github.com/pre-commit/mirrors-mypy rev: v0.931 hooks: - id: mypy exclude: ^(docs/|test/|setup.py).*$ args: ["--ignore-missing-imports"] - repo: https://github.com/pre-commit/mirrors-isort rev: v5.10.1 hooks: - id: isort additional_dependencies: ["isort[pyproject]"] - repo: https://github.com/pre-commit/mirrors-pylint rev: v3.0.0a4 hooks: - id: pylint additional_dependencies: ["isort[pyproject]"] exclude: ^(docs/|test/).*$ # disabled import-error as may be run out of environment with deps args: ["--disable=import-error"] pytest-click-1.1.0/setup.py0000644000175000017500000000311514201423467015165 0ustar jeromejerome#!/usr/bin/env python from os import path from setuptools import find_packages, setup this_directory = path.abspath(path.dirname(__file__)) with open(path.join(this_directory, "README.rst")) as fd: long_description = fd.read() requirements = [ "click>=6.0", "pytest>=5.0", ] setup( name="pytest_click", version="1.1.0", url="https://github.com/Stranger6667/pytest-click", license="MIT", author="Dmitry Dygalo", author_email="dadygalo@gmail.com", maintainer="Dmitry Dygalo", maintainer_email="dadygalo@gmail.com", description="Pytest plugin for Click", long_description=long_description, long_description_content_type="text/x-rst", classifiers=[ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "Operating System :: OS Independent", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Testing", ], include_package_data=True, packages=find_packages(where="src"), package_dir={"": "src"}, install_requires=requirements, entry_points={ "pytest11": [ "pytest_click = pytest_click", ] }, ) pytest-click-1.1.0/CHANGELOG.md0000644000175000017500000000125314201423467015265 0ustar jeromejeromeHistory ------- 1.1.0 - 11.02.2022 ------------------ - Added build for Python 3.10 - Drop support of Python 3.5 & 3.6 1.0.2 - 29.08.2020 ------------------ - Format code examples with "black". 1.0.1 - 29.08.2020 ------------------ - Include "test" to the package itself. 1.0.0 - 29.08.2020 ------------------ - Added builds for Python 3.8 & 3.9 - Drop support for Python 2.7 & 3.4 0.3.1 - 28.08.2020 ------------------ - Move to `src` layout 0.3 - 05.01.2019 ---------------- * Added Python 3.7 support * Dropped support for Python 2.6, 3.3 and Jython 0.2 - 13.04.2017 ---------------- * Added Python 3.6 support 0.1 - 29.01.2016 ---------------- * Initial release.