diff --git a/code_quality_tools/tests/fixtures/pep8.py b/code_quality_tools/tests/fixtures/pep8.py index 19c3622..0ba4d8c 100644 --- a/code_quality_tools/tests/fixtures/pep8.py +++ b/code_quality_tools/tests/fixtures/pep8.py @@ -1,4 +1,4 @@ - + def myFunction(): return 1 + 1 diff --git a/code_quality_tools/tests/test_code_quality_tools.py b/code_quality_tools/tests/test_code_quality_tools.py index aed263e..ae9bf82 100644 --- a/code_quality_tools/tests/test_code_quality_tools.py +++ b/code_quality_tools/tests/test_code_quality_tools.py @@ -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): @@ -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'] @@ -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): @@ -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): @@ -91,6 +101,10 @@ 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): @@ -98,11 +112,17 @@ def test_get_csslint_errors(self): 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)) @@ -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):