Skip to content

anujydv/autohooks-plugin-pytest

Repository files navigation

autohooks-plugin-pytest Build Status

An autohooks plugin for python code testing via pytest.

Installation

Install using pip

You can install the latest stable release of autohooks-plugin-pytest from the Python Package Index using pip:

pip install autohooks-plugin-pytest

Note the pip refers to the Python 3 package manager. In a environment where Python 2 is also available the correct command may be pip3.

Install using pipenv

It is highly encouraged to use pipenv for maintaining your project's dependencies. Normally autohooks-plugin-pytest is installed as a development dependency.

pipenv install --dev autohooks-plugin-pytest

Usage

To activate the pytest autohooks plugin please add the following setting to your pyproject.toml file.

[tool.autohooks]
pre-commit = ["autohooks.plugins.pytest"]

Customizing the pytest behavior

To pass options to pytest, you have to add an additional

[tool.autohooks.plugins.pytest]
option = "value"

block to your pyproject.toml file. Possible options are explained in the following.

  • Update root dir

    By default, autohooks plugin pytest checks all files with a "test_*.py" inside tests directory . To update root directory just add the following setting:

    root_dir = "api_test"
  • Select different view mode

    You can update the pytest cli view mode. some modes are :

    • quite "-q"
    • non-verbose "-rf"
    view_mode = "-q"

    default mode "-v" verbose.

  • Set coverage source

    You have to update the coverage directory :

    cov_source = "src"

    default direcotry is "src" .

  • Set coverage on pytest fail

    You can update the coverage on pytest fail :

    cov_on_fail = false

    default value is true .

  • Set coverage under fail

    You can update the coverage :

    cov_under_fail = 80

    default percentage is 100 .

  • Set coverage report format

    You can update the coverage report format :

    cov_report_format = "html"

    default report format is "xml" .

Contributing

Your contributions are highly appreciated. Please create a pull request on GitHub. Bigger changes need to be discussed with the development team via the issues section at GitHub first.

License

Licensed under the GNU General Public License v3.0 or later.