Skip to content

Commit

Permalink
Merge pull request Bachmann1234#1 from hugovk/intergration_test
Browse files Browse the repository at this point in the history
Add intergration tests for Pyflakes
  • Loading branch information
hugovk committed Jun 1, 2014
2 parents ba32efb + 99d4647 commit 02f2019
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 29 deletions.
2 changes: 1 addition & 1 deletion diff_cover/tests/fixtures/empty_pep8_violations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Diff: origin/master...HEAD, staged, and unstaged changes
-------------
violations_test_file.py (100%)
-------------
Total: 8 line(s)
Total: 9 line(s)
Violations: 0 line(s)
% Quality: 100%
-------------
1 change: 1 addition & 0 deletions diff_cover/tests/fixtures/git_diff_violations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ index 8bf3de7..4e4b0df 100644
+ for char in spongebob:
+ if char in squarepants:
+ return char
+ unused=1
+ return None
1 change: 1 addition & 0 deletions diff_cover/tests/fixtures/pep8_report.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
violations_test_file.py:2:13: E225 missing whitespace around operator
violations_test_file.py:3:23: W291 trailing whitespace
violations_test_file.py:6:1: E302 expected 2 blank lines, found 0
violations_test_file.py:11:11: E225 missing whitespace around operator
9 changes: 5 additions & 4 deletions diff_cover/tests/fixtures/pep8_violations_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ <h1>Diff Quality</h1>
</tr>
<tr>
<td>violations_test_file.py</td>
<td>75.0%</td>
<td>66.7%</td>
<td>
<ul>
<li>2: E225 missing whitespace around operator</li>
<li>6: E302 expected 2 blank lines, found 0</li>
<li>11: E225 missing whitespace around operator</li>
</ul>
</td>
</tr>
</table>
<ul>
<li><b>Total</b>: 8 line(s)</li>
<li><b>Violation</b>: 2 line(s)</li>
<li><b>% Quality</b>: 75%</li>
<li><b>Total</b>: 9 line(s)</li>
<li><b>Violation</b>: 3 line(s)</li>
<li><b>% Quality</b>: 66%</li>
</ul>
</body>
</html>
9 changes: 5 additions & 4 deletions diff_cover/tests/fixtures/pep8_violations_report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ Diff Quality
Quality Report: pep8
Diff: origin/master...HEAD, staged, and unstaged changes
-------------
violations_test_file.py (75.0%):
violations_test_file.py (66.7%):
2: E225 missing whitespace around operator
6: E302 expected 2 blank lines, found 0
11: E225 missing whitespace around operator
-------------
Total: 8 line(s)
Violations: 2 line(s)
% Quality: 75%
Total: 9 line(s)
Violations: 3 line(s)
% Quality: 66%
-------------
33 changes: 33 additions & 0 deletions diff_cover/tests/fixtures/pyflakes_violations_report.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>Diff Quality</title>
</head>
<body>
<h1>Diff Quality</h1>
<p>Quality Report: pyflakes</p>
<p>Diff: origin/master...HEAD, staged, and unstaged changes</p>
<table border="1">
<tr>
<th>Source File</th>
<th>Diff Quality (%)</th>
<th>Line(s) in violation</th>
</tr>
<tr>
<td>violations_test_file.py</td>
<td>88.9%</td>
<td>
<ul>
<li>11: local variable 'unused' is assigned to but never used</li>
</ul>
</td>
</tr>
</table>
<ul>
<li><b>Total</b>: 9 line(s)</li>
<li><b>Violation</b>: 1 line(s)</li>
<li><b>% Quality</b>: 88%</li>
</ul>
</body>
</html>
12 changes: 12 additions & 0 deletions diff_cover/tests/fixtures/pyflakes_violations_report.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-------------
Diff Quality
Quality Report: pyflakes
Diff: origin/master...HEAD, staged, and unstaged changes
-------------
violations_test_file.py (88.9%):
11: local variable 'unused' is assigned to but never used
-------------
Total: 9 line(s)
Violations: 1 line(s)
% Quality: 88%
-------------
10 changes: 6 additions & 4 deletions diff_cover/tests/fixtures/pylint_violations_console_report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ Diff Quality
Quality Report: pylint
Diff: origin/master...HEAD, staged, and unstaged changes
-------------
violations_test_file.py (75.0%):
violations_test_file.py (66.7%):
1: C0111: (missing-docstring), : Missing module docstring
1: C0111: (missing-docstring), func_1: Missing function docstring
2: C0326: (bad-whitespace), : Exactly one space required around comparison
11: C0326: (bad-whitespace), : Exactly one space required around assignment
11: W0612: (unused-variable), func_2: Unused variable 'unused'
-------------
Total: 8 line(s)
Violations: 2 line(s)
% Quality: 75%
Total: 9 line(s)
Violations: 3 line(s)
% Quality: 66%
-------------
10 changes: 6 additions & 4 deletions diff_cover/tests/fixtures/pylint_violations_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@ <h1>Diff Quality</h1>
</tr>
<tr>
<td>violations_test_file.py</td>
<td>75.0%</td>
<td>66.7%</td>
<td>
<ul>
<li>1: C0111: (missing-docstring), : Missing module docstring</li>
<li>1: C0111: (missing-docstring), func_1: Missing function docstring</li>
<li>2: C0326: (bad-whitespace), : Exactly one space required around comparison</li>
<li>11: C0326: (bad-whitespace), : Exactly one space required around assignment</li>
<li>11: W0612: (unused-variable), func_2: Unused variable 'unused'</li>
</ul>
</td>
</tr>
</table>
<ul>
<li><b>Total</b>: 8 line(s)</li>
<li><b>Violation</b>: 2 line(s)</li>
<li><b>% Quality</b>: 75%</li>
<li><b>Total</b>: 9 line(s)</li>
<li><b>Violation</b>: 3 line(s)</li>
<li><b>% Quality</b>: 66%</li>
</ul>
</body>
</html>
6 changes: 3 additions & 3 deletions diff_cover/tests/fixtures/pylint_violations_report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ Diff Quality
Quality Report: pylint
Diff: origin/master...HEAD, staged, and unstaged changes
-------------
violations_test_file.py (75.0%):
violations_test_file.py (77.8%):
1: C0111: Missing docstring
1: C0111: func_1: Missing docstring
2: C0322: func_1: Operator not preceded by a space
-------------
Total: 8 line(s)
Total: 9 line(s)
Violations: 2 line(s)
% Quality: 75%
% Quality: 77%
-------------
1 change: 1 addition & 0 deletions diff_cover/tests/fixtures/violations_test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ def func_2(spongebob, squarepants):
for char in spongebob:
if char in squarepants:
return char
unused=1
return None
42 changes: 33 additions & 9 deletions diff_cover/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,13 @@ def test_added_file_pep8_html(self):
['diff-quality', '--violations=pep8']
)

def test_added_file_pyflakes_html(self):
self._check_html_report(
'git_diff_violations.txt',
'pyflakes_violations_report.html',
['diff-quality', '--violations=pyflakes']
)

def test_added_file_pylint_html(self):
self._check_html_report(
'git_diff_violations.txt',
Expand All @@ -299,21 +306,18 @@ def test_added_file_pep8_console_exclude_file(self):
['diff-quality', '--violations=pep8', '--options="--exclude=violations_test_file.py"']
)

def test_added_file_pylint_console(self):
def test_added_file_pyflakes_console(self):
self._check_console_report(
'git_diff_violations.txt',
'pylint_violations_console_report.txt',
['diff-quality', '--violations=pylint'],
'pyflakes_violations_report.txt',
['diff-quality', '--violations=pyflakes']
)

def test_pre_generated_pylint_report(self):

# Pass in a pre-generated pylint report instead of letting
# the tool call pylint itself.
def test_added_file_pylint_console(self):
self._check_console_report(
'git_diff_violations.txt',
'pylint_violations_report.txt',
['diff-quality', '--violations=pylint', 'pylint_report.txt']
'pylint_violations_console_report.txt',
['diff-quality', '--violations=pylint'],
)

def test_pre_generated_pep8_report(self):
Expand All @@ -325,3 +329,23 @@ def test_pre_generated_pep8_report(self):
'pep8_violations_report.txt',
['diff-quality', '--violations=pep8', 'pep8_report.txt']
)

def test_pre_generated_pyflakes_report(self):

# Pass in a pre-generated pyflakes report instead of letting
# the tool call pyflakes itself.
self._check_console_report(
'git_diff_violations.txt',
'pyflakes_violations_report.txt',
['diff-quality', '--violations=pyflakes', 'pyflakes_report.txt']
)

def test_pre_generated_pylint_report(self):

# Pass in a pre-generated pylint report instead of letting
# the tool call pylint itself.
self._check_console_report(
'git_diff_violations.txt',
'pylint_violations_report.txt',
['diff-quality', '--violations=pylint', 'pylint_report.txt']
)

0 comments on commit 02f2019

Please sign in to comment.