Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code_quality_tools/tests/fixtures/pep8.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

def myFunction():
return 1 + 1

Expand Down
29 changes: 25 additions & 4 deletions code_quality_tools/tests/test_code_quality_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def test_get_pep8_errors(self):
errors = self.check.get_pep8_errors(path_fixture)
self.assertEqual(errors['total_errors'], 3)
self.assertEqual(len(errors['list_errors']), 3)
self.assertTrue(path_fixture + ":1:1: W293 blank line contains whitespace" in errors['list_errors'])
self.assertTrue(path_fixture + ":5:1: E302 expected 2 blank lines, found 1" in errors['list_errors'])
self.assertTrue(path_fixture + ":6:17: W292 no newline at end of file" in errors['list_errors'])
self.assertEqual(errors['percentage_errors'], 50.0)

def test_get_pep8_errors_with_extra_options(self):
Expand All @@ -47,9 +50,12 @@ def test_get_pep8_errors_with_extra_options(self):
path_fixture,
options=['--ignore=E302']
)
self.assertEqual(errors['total_errors'], 1)
self.assertEqual(len(errors['list_errors']), 1)
self.assertEqual(errors['percentage_errors'], 16.67)
self.assertEqual(errors['total_errors'], 2)
self.assertEqual(len(errors['list_errors']), 2)
self.assertTrue(path_fixture + ":1:1: W293 blank line contains whitespace" in errors['list_errors'])
self.assertFalse(path_fixture + ":5:1: E302 expected 2 blank lines, found 1" in errors['list_errors'])
self.assertTrue(path_fixture + ":6:17: W292 no newline at end of file" in errors['list_errors'])
self.assertEqual(errors['percentage_errors'], 33.33)

def test_get_pep8_errors_saving_in_output_file(self):
output_file = self.out_files['pep8']
Expand All @@ -62,6 +68,8 @@ def test_get_pyflakes_errors(self):
errors = self.check.get_pyflakes_errors(path_fixture)
self.assertEqual(errors['total_errors'], 2)
self.assertEqual(len(errors['list_errors']), 2)
self.assertTrue(path_fixture + ":1: 're' imported but unused" in errors['list_errors'])
self.assertTrue(path_fixture + ":2: 'sys' imported but unused" in errors['list_errors'])
self.assertEqual(errors['percentage_errors'], 28.57)

def test_get_pyflakes_errors_saving_in_output_file(self):
Expand All @@ -75,6 +83,8 @@ def test_get_jshint_errors(self):
errors = self.check.get_jshint_errors(path_fixture)
self.assertEqual(errors['total_errors'], 2)
self.assertEqual(len(errors['list_errors']), 2)
self.assertTrue(path_fixture + ": line 1, col 11, Missing semicolon." in errors['list_errors'])
self.assertTrue(path_fixture + ": line 2, col 11, Missing semicolon." in errors['list_errors'])
self.assertEqual(errors['percentage_errors'], 33.33)

def test_get_jshint_errors_saving_in_output_file(self):
Expand All @@ -91,18 +101,28 @@ def test_get_jshint_errors_with_extra_options(self):
)
self.assertEqual(errors['total_errors'], 4)
self.assertEqual(len(errors['list_errors']), 4)
self.assertTrue(path_fixture + "jshint.js: line 1, col 11, Missing semicolon." in errors['list_errors'])
self.assertTrue(path_fixture + "jshint.js: line 2, col 11, Missing semicolon." in errors['list_errors'])
self.assertTrue(path_fixture + "jshint_with_extension.jss: line 1, col 11, Missing semicolon." in errors['list_errors'])
self.assertTrue(path_fixture + "jshint_with_extension.jss: line 2, col 11, Missing semicolon." in errors['list_errors'])
self.assertEqual(errors['percentage_errors'], 66.67)

def test_get_csslint_errors(self):
path_fixture = self.path_fixtures + 'csslint.css'
errors = self.check.get_csslint_errors(path_fixture)
self.assertEqual(errors['total_errors'], 6)
self.assertEqual(len(errors['list_errors']), 6)
self.assertTrue(path_fixture + ": line 1, col 1, Warning - Don't use IDs in selectors." in errors['list_errors'])
self.assertTrue(path_fixture + ": line 2, col 20, Warning - Values of 0 shouldn't have units specified." in errors['list_errors'])
self.assertTrue(path_fixture + ": line 3, col 25, Warning - Values of 0 shouldn't have units specified." in errors['list_errors'])
self.assertTrue(path_fixture + ": line 3, col 5, Warning - Standard property 'border-radius' should come after vendor-prefixed property '-moz-border-radius'." in errors['list_errors'])
self.assertTrue(path_fixture + ": line 4, col 28, Warning - Values of 0 shouldn't have units specified." in errors['list_errors'])
self.assertTrue(path_fixture + ": line 4, col 5, Warning - Standard property 'border-radius' should come after vendor-prefixed property '-webkit-border-radius'." in errors['list_errors'])
self.assertEqual(errors['percentage_errors'], 120.0)

def test_get_csslint_errors_saving_in_output_file(self):
output_file = self.out_files['csslint']
path_fixture = self.path_fixtures + 'csslint.py'
path_fixture = self.path_fixtures + 'csslint.css'
self.check.get_csslint_errors(path_fixture, output_file)
self.assertTrue(isfile(output_file))

Expand All @@ -114,6 +134,7 @@ def test_get_csslint_errors_with_extra_options(self):
)
self.assertEqual(errors['total_errors'], 1)
self.assertEqual(len(errors['list_errors']), 1)
self.assertTrue(path_fixture + ": line 1, col 1, Error - Don't use IDs in selectors." in errors['list_errors'])
self.assertEqual(errors['percentage_errors'], 20.0)

def test_get_clonedigger_errors(self):
Expand Down