Skip to content

Commit

Permalink
Merge eea9f68 into 3d03fd8
Browse files Browse the repository at this point in the history
  • Loading branch information
carsongee committed Apr 25, 2020
2 parents 3d03fd8 + eea9f68 commit c03966d
Show file tree
Hide file tree
Showing 8 changed files with 387 additions and 97 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Expand Up @@ -59,3 +59,13 @@ target/

# PyEnv
.python-version

# Virtualenv
.venv
.pytest-pylint

# Pycharm
.idea

# Vscode
.vscode
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -7,7 +7,7 @@ matrix:
- python: 3.6
- python: 3.5
install:
- "pip install tox-travis tox==3.14.0 coveralls"
- "pip install tox-travis tox==3.14.6 coveralls"
- "pip install -e ."
script: tox
after_success:
Expand Down
50 changes: 50 additions & 0 deletions DEVELOPMENT.md
@@ -0,0 +1,50 @@

Helpers for running pylint with py.test and have configurable rule
types (i.e. Convention, Warn, and Error) fail the
build. You can also specify a pylintrc file.

How it works

We have a thin plugin wrapper that is installed through setup.py hooks as `pylint`.
This wrapper uses pytest_addoption and pytest_configure to decide to configure and
register the real plugin PylintPlygin

Once it is registered in `pytest_configure`, the hooks already executed
by previous plugins will run. For instance, in case PylintPlugin had
`pytest_addoption` implemented, which runs before `pytest_configure`
in the hook cycle, it would be executed once PylintPlugin got registered.

PylintPlugin uses the `pytest_collect_file` hook which is called wih every
file available in the test target dir. This hook collects all the file
pylint should run on, in this case files with extension ".py".

`pytest_collect_file` hook returns a collection of Node, or None. In
py.test context, Node being a base class that defines py.test Collection
Tree.

A Node can be a subclass of Collector, which has children, or an Item, which
is a leaf node.

A practical example would be, a Python test file (Collector), can have multiple
test functions (multiple Items)

For this plugin, the relatioship of File to Item is one to one, one
file represents one pylint result.

From that, there are two important classes: PyLintFile, and PyLintItem.

PyLintFile represents a python file, extension ".py", that was
collected based on target directory as mentioned previously.

PyLintItem represents one file which pylint was ran or will run.

Back to PylintPlugin, `pytest_collection_finish` hook will run after the
collection phase where pylint will be ran on the collected files.

Based on the ProgrammaticReporter, the result is stored in a dictionary
with the file relative path of the file being the key, and a list of
errors related to the file.

All PylintFile returned during `pytest_collect_file`, returns an one
element list of PyLintItem. The Item implements runtest method which will
get the pylint messages per file and expose to the user.
12 changes: 11 additions & 1 deletion README.rst
Expand Up @@ -45,10 +45,20 @@ Acknowledgements
This code is heavily based on
`pytest-flakes <https://github.com/fschulze/pytest-flakes>`__

Development
===========

If you want to help development, there is
`overview documentation <https://github.com/carsongee/pytest-pylint//lob/master/DEVELOPMENT.rst>`_

Releases
========

0.16.0
~~~~~~
- Switched to new ``from_parent`` API and added development documentation `dineshtrivedi <https://github.com/dineshtrivedi>`_
- Added support for toml based configuration of pylint thanks to `michael-k <https://github.com/michael-k>`_

0.15.1
~~~~~~

Expand All @@ -57,7 +67,7 @@ Releases
0.15.0
~~~~~~

- Added support for Python 3.8 thanks to `yanqd0 <https://github.com/michael-k>`_
- Added support for Python 3.8 thanks to `michael-k <https://github.com/michael-k>`_
- Implemented option to output Pylint results to a reports file thanks to `jose-lpa <https://github.com/jose-lpa>`_
- Refactored into simpler plugin structure

Expand Down

0 comments on commit c03966d

Please sign in to comment.