Skip to content

Latest commit

 

History

History
110 lines (72 loc) · 3.37 KB

CONTRIBUTING.rst

File metadata and controls

110 lines (72 loc) · 3.37 KB

Contributing to pycodestyle

When contributing to pycodestyle, please observe our Code of Conduct.

Step 1: Forking pycodestyle for editing

Fork the pycodestyle repository on GitHub. This will add pycodestyle to your GitHub account. You will push your changes to your fork and then make pull requests into the official pycodestyle repository.

GitHub has an excellent guide that has screenshots on how to do this.

Next, clone your fork of the pycodestyle repository to your system for editing:

$ git clone https://www.github.com/<your_username>/pycodestyle

Now you have a copy of the pycodestyle codebase that is almost ready for edits. Next we will setup virtualenv which will help create an isolated environment to manage dependencies.

Step 2: Use virtualenv when developing

virtualenv is a tool to create isolated python environments. First, install virtualenv with:

$ pip install virtualenv

Next, cd to the pycodestyle repository that you cloned earlier and create, then activate a virtualenv:

$ cd pycodestyle
$ virtualenv pycodestyle-venv
$ source pycodestyle-venv/bin/activate

Now you can install the pycodestyle requirements:

$ pip install -r dev-requirements.txt

To deactivate the virtualenv you can type:

$ deactivate

For more information see virtualenv's documentation.

Step 3: Run tests

Before creating a pull request you should run the tests to make sure that the changes that have been made haven't caused any regressions in functionality. To run the tests, the core developer team and Travis-CI use tox:

$ pip install -r dev-requirements.txt
$ tox

All the tests should pass for all available interpreters, with the summary of:

congratulations :)

At this point you can create a pull request back to the official pycodestyles repository for review! For more information on how to make a pull request, GitHub has an excellent guide.

The current tests are written in 2 styles:

  • standard xUnit based only on stdlib unittest (can be executed with nose)
  • functional test using a custom framework and executed by the pycodestyle itself when installed in dev mode.

Running unittest

While the tests are writted using stdlib unittest module, the existing test include unit, integration and functional tests.

There are a couple of ways to run the tests:

$ python setup.py test
$ # Use nose to run specific test
$ nosetests \
>    testsuite.test_blank_lines:TestBlankLinesDefault.test_initial_no_blank
$ # Use nose to run a subset and check coverage, and check the resulting
$ $ cover/pycodestyle_py.html in your browser
$ nosetests --with-coverage --cover-html -s testsuite.test_blank_lines

Running functional

When installed in dev mode, pycodestyle will have the --testsuite option which can be used to run the tests:

$ pip install -e .
$ # Run all tests.
$ pycodestyle --testsuite testsuite
$ # Run a subset of the tests.
$ pycodestyle --testsuite testsuite/E30.py