项目作者: codeclimate

项目描述 :
DEPRECATED Uploads Python test coverage data to Code Climate
高级语言: Python
项目地址: git://github.com/codeclimate/python-test-reporter.git
创建时间: 2016-04-01T19:08:34Z
项目社区:https://github.com/codeclimate/python-test-reporter

开源协议:Other

下载


codeclimate-test-reporter - [DEPRECATED]

These configuration instructions refer to a language-specific test reporter which is now deprecated in favor of our new unified test reporter client. The new test reporter is faster, distributed as a static binary, has support for parallelized CI builds, and will receive ongoing support by the team here. The existing test reporters for Ruby, Python, PHP, and Javascript are now deprecated.
Code Climate
Test Coverage
PyPI version

Collects test coverage data from your Python test suite and sends it to Code
Climate’s hosted, automated code review service.

Code Climate - https://codeclimate.com

Uploading Your Test Coverage Report

The codeclimate-test-reporter is compatible with coverage.py coverage
reports. By default, coverage.py will generate a .coverage file in the current
directory. codeclimate-test-reporter, run without arguments, will
look for a coverage report at this default location.

Note: The codeclimate-test-reporter requires a repo token from
codeclimate.com, so if you don’t have one, the first step is to signup
and configure your repo. Then:

You can place the repo token in the environment under the key
CODECLIMATE_REPO_TOKEN or pass the token as a CLI argument:

  1. $ CODECLIMATE_REPO_TOKEN=[token] codeclimate-test-reporter
  2. Submitting payload to https://codeclimate.com... done!
  1. $ codeclimate-test-reporter --token [token]
  2. Submitting payload to https://codeclimate.com... done!

We recommend configuring the repo token in the environment through your CI
settings which will hide the value during runs. The token should be considered a
scoped password. Anyone with the token can submit test coverage data to your
Code Climate repo.

  1. # CODECLIMATE_REPO_TOKEN already set in env
  2. $ codeclimate-test-reporter
  3. Submitting payload to https://codeclimate.com... done!

Generating Coverage Reports

To generate a coverage report with pytest, you can use the pytest-cov
plugin:

  1. $ py.test --cov=your_package tests/
  2. TOTAL 284 27 90%
  3. ======================== 14 passed in 0.75 seconds ========================

To generate a coverage report with nose, you can use the nose cover plugin:

  1. $ nosetests --with-coverage --cover-erase --cover-package=your_package
  2. TOTAL 284 27 90%
  3. ----------------------------------------------------------------------
  4. Ran 14 tests in 0.743s
  5. OK

By default, coverage.py will create the test coverage report at ./.coverage.
If you configure coverage.py to generate a coverage report at an alternate
location, pass that to the codeclimate-test-reporter:

  1. $ codeclimate-test-reporter --file ./alternate/location/.coverage
  2. Submitting payload to https://codeclimate.com... done!

Installation

You can install the codeclimate-test-reporter using pip:

  1. $ pip install codeclimate-test-reporter
  2. Successfully installed codeclimate-test-reporter-[version]

Or you can add the reporter to your requirements.txt file and install it along
with other project dependencies:

  1. # requirements.txt
  2. codeclimate-test-reporter
  1. $ pip install -r requirements.txt
  2. Successfully installed codeclimate-test-reporter-[version]

Important FYIs

Across the many different testing frameworks, setups, and environments, there
are lots of variables at play. Before setting up test coverage, it’s important
to understand what we do and do not currently support:

  • Single payload: We currently only support a single test coverage payload
    per commit. If you run your tests in multiple steps, or via parallel tests,
    Code Climate will only process the first payload that we receive. If you are
    using a CI, be sure to check if you are running your tests in a parallel mode.

    Note: If you’ve configured Code Climate to analyze multiple languages in
    the same repository (e.g., Python and JavaScript), we can nonetheless only
    process test coverage information for one of these languages. We’ll process
    the first payload that we receive.

  • Invalid File Paths: By default, our test reporters expect your application
    to exist at the root of your repository. If this is not the case, the file
    paths in your test coverage payload will not match the file paths that Code
    Climate expects.

Troubleshooting

If you’re having trouble setting up or working with our test coverage feature,
see our detailed help doc, which covers the most common issues encountered.

If the issue persists, feel free to open up an issue here or contact
help with debug information from the reporter:

  1. $ codeclimate-test-reporter --debug
  2. codeclimate-test-reporter [version]
  3. Requests 2.9.1
  4. Python 3.5.1 (default, Jan 22 2016, 08:54:32)
  5. [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)]
  6. /usr/local/opt/python3/bin/python3.5
  7. Darwin 15.4.0

Contributions

Patches, bug fixes, feature requests, and pull requests are welcome.

Development

A Dockerfile is included for developer convenience. Simply run make test to
run the test suite and coverage report.

To release a new version, first run ./bin/prep-release [version] to bump the
version and open a PR on GitHub.

Once the PR is merged, run make release to publish the new version to pypy and
create a tag on GitHub. This step requires pypy credentials at ~/.pypirc. You
can copy this repo’s .pypirc.sample file as a starting point.

See LICENSE.txt