Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
agroszer committed Nov 14, 2017
2 parents b66a1cd + 606147d commit 3b56252
Show file tree
Hide file tree
Showing 22 changed files with 96 additions and 107 deletions.
16 changes: 10 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
language: python
matrix:
include:
- python: 2.7
env: TOXENV=py27
- python: 3.4
env: TOXENV=py34
- python: 3.5
env: TOXENV=py35
env:
- TOXENV=py26
- TOXENV=py27
- TOXENV=py33
- TOXENV=py34
- TOXENV=pypy
- python: 3.6
env: TOXENV=py36
- python: pypy
env: TOXENV=pypy
- python: pypy3
env: TOXENV=pypy3
install:
- travis_retry pip install coveralls tox
script:
Expand Down
22 changes: 11 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ diff-cover |build-status| |coverage-status| |docs-status|
=========================================================

Automatically find diff lines that need test coverage.
Also finds diff lines that have violations (according to tools such as pep8,
Also finds diff lines that have violations (according to tools such as pycodestyle,
pyflakes, flake8, or pylint).
This is used as a code quality metric during code reviews.

Expand Down Expand Up @@ -119,7 +119,7 @@ You can use diff-cover to see quality reports on the diff as well by running
diff-quality --violations=<tool>
Where ``tool`` is the quality checker to use. Currently ``pep8``, ``pyflakes``,
Where ``tool`` is the quality checker to use. Currently ``pycodestyle``, ``pyflakes``,
``flake8``, and ``pylint`` are supported, but more checkers can (and should!)
be integrated.

Expand All @@ -129,9 +129,9 @@ Like ``diff-cover``, HTML reports can be generated with
diff-quality --violations=<tool> --html-report report.html
If you have already generated a report using ``pep8``, ``pyflakes``, ``flake8``,
If you have already generated a report using ``pycodestyle``, ``pyflakes``, ``flake8``,
or ``pylint`` you can pass the report to ``diff-quality``. This is more
efficient than letting ``diff-quality`` re-run ``pep8``, ``pyflakes``,
efficient than letting ``diff-quality`` re-run ``pycodestyle``, ``pyflakes``,
``flake8``, or ``pylint``.

.. code:: bash
Expand All @@ -145,15 +145,15 @@ efficient than letting ``diff-quality`` re-run ``pep8``, ``pyflakes``,
# Use the generated pylint report when running diff-quality
diff-quality --violations=pylint pylint_report.txt
# Use a generated pep8 report when running diff-quality.
pep8 > pep8_report.txt
diff-quality --violations=pep8 pep8_report.txt
# Use a generated pycodestyle report when running diff-quality.
pycodestyle > pycodestyle_report.txt
diff-quality --violations=pycodestyle pycodestyle_report.txt
Note that you must use the ``-f parseable`` option to generate
the ``pylint`` report for pylint versions less than 1.0 and the
``--msg-template`` option for versions >= 1.0.

``diff-quality`` will also accept multiple ``pep8``, ``pyflakes``, ``flake8``,
``diff-quality`` will also accept multiple ``pycodestyle``, ``pyflakes``, ``flake8``,
or ``pylint`` reports:

.. code:: bash
Expand All @@ -164,7 +164,7 @@ If you need to pass in additional options you can with the ``options`` flag

.. code:: bash
diff-quality --violations=pep8 --options="--exclude='*/migrations*' --statistics" pep8_report.txt
diff-quality --violations=pycodestyle --options="--exclude='*/migrations*' --statistics" pycodestyle_report.txt
Compare Branch
--------------
Expand All @@ -184,7 +184,7 @@ below a certain threshold specify the fail-under parameter
.. code:: bash
diff-cover coverage.xml --fail-under=80
diff-quality --violations=pep8 --fail-under=80
diff-quality --violations=pycodestyle --fail-under=80
The above will return a non zero status if the coverage or quality score was below 80%

Expand Down Expand Up @@ -263,7 +263,7 @@ For example, setting up python 3:
pyvenv venv
source venv/bin/activate
pip install -r test-requirements-py27-py3.txt
pip install -r test-requirements.txt
Special Thanks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-------------
Diff Quality
Quality Report: pep8
Quality Report: pycodestyle
Diff: origin/master...HEAD, staged and unstaged changes
-------------
violations_test_file.py (100%)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
</head>
<body>
<h1>Diff Quality</h1>
<p>Quality Report: pep8</p>
<p>Quality Report: pycodestyle</p>
<p>Diff: origin/master...HEAD, staged and unstaged changes</p>
<table border="1">
<tr>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-------------
Diff Quality
Quality Report: pep8
Quality Report: pycodestyle
Diff: origin/master...HEAD, staged and unstaged changes
-------------
violations_test_file.py (66.7%):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</head>
<body>
<h1>Diff Quality</h1>
<p>Quality Report: pep8</p>
<p>Quality Report: pycodestyle</p>
<p>Diff: origin/master...HEAD, staged and unstaged changes</p>
<table border="1">
<tr>
Expand Down
6 changes: 0 additions & 6 deletions diff_cover/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@
Test helper functions.
"""
import random
import sys

import io
import six
import os.path
import difflib
from nose.tools import ok_

if sys.version_info[:2] <= (2, 6):
import unittest2 as unittest
else:
import unittest

HUNK_BUFFER = 2
MAX_LINE_LENGTH = 300
LINE_STRINGS = ['test', '+ has a plus sign', '- has a minus sign']
Expand Down
10 changes: 5 additions & 5 deletions diff_cover/tests/test_args.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import unicode_literals
import contextlib
import sys
from mock import Mock, patch
from mock import patch
from diff_cover.tool import parse_coverage_args, parse_quality_args, main
from diff_cover.tests.helpers import unittest
import unittest


@contextlib.contextmanager
Expand Down Expand Up @@ -93,12 +93,12 @@ def test_parse_with_exclude(self):
class ParseQualityArgsTest(unittest.TestCase):

def test_parse_with_html_report(self):
argv = ['--violations', 'pep8',
argv = ['--violations', 'pycodestyle',
'--html-report', 'diff_cover.html']

arg_dict = parse_quality_args(argv)

self.assertEqual(arg_dict.get('violations'), 'pep8')
self.assertEqual(arg_dict.get('violations'), 'pycodestyle')
self.assertEqual(arg_dict.get('html_report'), 'diff_cover.html')
self.assertEqual(arg_dict.get('input_reports'), [])
self.assertEqual(arg_dict.get('ignore_unstaged'), False)
Expand Down Expand Up @@ -131,7 +131,7 @@ def test_parse_with_multiple_input_reports(self):

def test_parse_with_options(self):
argv = [
'--violations', 'pep8',
'--violations', 'pycodestyle',
'--options="--exclude=\'*/migrations*\'"'
]
arg_dict = parse_quality_args(argv)
Expand Down
3 changes: 2 additions & 1 deletion diff_cover/tests/test_diff_reporter.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import mock
import unittest
from textwrap import dedent
from diff_cover.diff_reporter import GitDiffReporter
from diff_cover.git_diff import GitDiffTool, GitDiffError
from diff_cover.tests.helpers import line_numbers, git_diff_output, unittest
from diff_cover.tests.helpers import line_numbers, git_diff_output


class GitDiffReporterTest(unittest.TestCase):
Expand Down
4 changes: 2 additions & 2 deletions diff_cover/tests/test_git_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import mock

from diff_cover.command_runner import CommandError
from diff_cover.git_diff import GitDiffTool, GitDiffError
from diff_cover.tests.helpers import unittest
from diff_cover.git_diff import GitDiffTool
import unittest


class TestGitDiffTool(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion diff_cover/tests/test_git_path.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
import mock
from diff_cover.git_path import GitPathTool
from diff_cover.tests.helpers import unittest
import unittest


class TestGitPathTool(unittest.TestCase):
Expand Down
38 changes: 19 additions & 19 deletions diff_cover/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from collections import defaultdict
from io import BytesIO
from subprocess import Popen
from diff_cover.tests.helpers import unittest
import unittest
import io
import six

Expand Down Expand Up @@ -382,13 +382,13 @@ def test_git_diff_error_diff_quality(self):

# Expect an error
with self.assertRaises(CommandError):
main(['diff-quality', '--violations', 'pep8'])
main(['diff-quality', '--violations', 'pycodestyle'])

def test_added_file_pep8_html(self):
def test_added_file_pycodestyle_html(self):
self._check_html_report(
'git_diff_violations.txt',
'pep8_violations_report.html',
['diff-quality', '--violations=pep8']
'pycodestyle_violations_report.html',
['diff-quality', '--violations=pycodestyle']
)

def test_added_file_pyflakes_html(self):
Expand Down Expand Up @@ -424,24 +424,24 @@ def test_fail_under_pass_html(self):
def test_html_with_external_css(self):
temp_dir = self._check_html_report(
'git_diff_violations.txt',
'pep8_violations_report_external_css.html',
['diff-quality', '--violations=pep8'],
'pycodestyle_violations_report_external_css.html',
['diff-quality', '--violations=pycodestyle'],
css_file='external_style.css'
)
self.assertTrue(os.path.exists(os.path.join(temp_dir, 'external_style.css')))

def test_added_file_pep8_console(self):
def test_added_file_pycodestyle_console(self):
self._check_console_report(
'git_diff_violations.txt',
'pep8_violations_report.txt',
['diff-quality', '--violations=pep8']
'pycodestyle_violations_report.txt',
['diff-quality', '--violations=pycodestyle']
)

def test_added_file_pep8_console_exclude_file(self):
def test_added_file_pycodestyle_console_exclude_file(self):
self._check_console_report(
'git_diff_violations.txt',
'empty_pep8_violations.txt',
['diff-quality', '--violations=pep8', '--options="--exclude=violations_test_file.py"']
'empty_pycodestyle_violations.txt',
['diff-quality', '--violations=pycodestyle', '--options="--exclude=violations_test_file.py"']
)

def test_fail_under_console(self):
Expand Down Expand Up @@ -483,14 +483,14 @@ def test_added_file_pylint_console(self):
['diff-quality', '--violations=pylint'],
)

def test_pre_generated_pep8_report(self):
def test_pre_generated_pycodestyle_report(self):

# Pass in a pre-generated pep8 report instead of letting
# the tool call pep8 itself.
# Pass in a pre-generated pycodestyle report instead of letting
# the tool call pycodestyle itself.
self._check_console_report(
'git_diff_violations.txt',
'pep8_violations_report.txt',
['diff-quality', '--violations=pep8', 'pep8_report.txt']
'pycodestyle_violations_report.txt',
['diff-quality', '--violations=pycodestyle', 'pycodestyle_report.txt']
)

def test_pre_generated_pyflakes_report(self):
Expand Down Expand Up @@ -564,7 +564,7 @@ def test_do_nothing_reporter(self):
# should not do anything
# Does demonstrate a reporter can take in any tool
# name though which is cool
reporter = DoNothingDriver('pep8', [], [])
reporter = DoNothingDriver('pycodestyle', [], [])
self.assertEqual(reporter.parse_reports(''), {})


Expand Down
3 changes: 2 additions & 1 deletion diff_cover/tests/test_report_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
StringReportGenerator, TemplateReportGenerator
)
from diff_cover.tests.helpers import (
load_fixture, assert_long_str_equal, unittest
load_fixture, assert_long_str_equal
)
import unittest
from diff_cover.violationsreporters.violations_reporter import BaseViolationReporter, Violation


Expand Down
3 changes: 2 additions & 1 deletion diff_cover/tests/test_snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
from pygments.token import Token
from diff_cover.snippets import Snippet
from diff_cover.tests.helpers import load_fixture,\
fixture_path, assert_long_str_equal, unittest
fixture_path, assert_long_str_equal
import six
import unittest


class SnippetTest(unittest.TestCase):
Expand Down

0 comments on commit 3b56252

Please sign in to comment.