Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/common_unittest.py

Issue 1839193004: Run auto-formatter (autopep8) on webkitpy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) 1 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org)
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions 4 # modification, are permitted provided that the following conditions
5 # are met: 5 # are met:
6 # 1. Redistributions of source code must retain the above copyright 6 # 1. Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # 2. Redistributions in binary form must reproduce the above copyright 8 # 2. Redistributions in binary form must reproduce the above copyright
9 # notice, this list of conditions and the following disclaimer in the 9 # notice, this list of conditions and the following disclaimer in the
10 # documentation and/or other materials provided with the distribution. 10 # documentation and/or other materials provided with the distribution.
(...skipping 15 matching lines...) Expand all
26 26
27 from common import CarriageReturnChecker 27 from common import CarriageReturnChecker
28 from common import TabChecker 28 from common import TabChecker
29 29
30 # FIXME: The unit tests for the cpp, text, and common checkers should 30 # FIXME: The unit tests for the cpp, text, and common checkers should
31 # share supporting test code. This can include, for example, the 31 # share supporting test code. This can include, for example, the
32 # mock style error handling code and the code to check that all 32 # mock style error handling code and the code to check that all
33 # of a checker's categories are covered by the unit tests. 33 # of a checker's categories are covered by the unit tests.
34 # Such shared code can be located in a shared test file, perhaps 34 # Such shared code can be located in a shared test file, perhaps
35 # even this file. 35 # even this file.
36
37
36 class CarriageReturnCheckerTest(unittest.TestCase): 38 class CarriageReturnCheckerTest(unittest.TestCase):
37 39
38 """Tests check_no_carriage_return().""" 40 """Tests check_no_carriage_return()."""
39 41
40 _category = "whitespace/carriage_return" 42 _category = "whitespace/carriage_return"
41 _confidence = 1 43 _confidence = 1
42 _expected_message = ("One or more unexpected \\r (^M) found; " 44 _expected_message = ("One or more unexpected \\r (^M) found; "
43 "better to use only a \\n") 45 "better to use only a \\n")
44 46
45 def setUp(self): 47 def setUp(self):
46 self._style_errors = [] # The list of accumulated style errors. 48 self._style_errors = [] # The list of accumulated style errors.
47 49
48 def _mock_style_error_handler(self, line_number, category, confidence, 50 def _mock_style_error_handler(self, line_number, category, confidence,
49 message): 51 message):
50 """Append the error information to the list of style errors.""" 52 """Append the error information to the list of style errors."""
51 error = (line_number, category, confidence, message) 53 error = (line_number, category, confidence, message)
52 self._style_errors.append(error) 54 self._style_errors.append(error)
53 55
54 def assert_carriage_return(self, input_lines, expected_lines, error_lines): 56 def assert_carriage_return(self, input_lines, expected_lines, error_lines):
55 """Process the given line and assert that the result is correct.""" 57 """Process the given line and assert that the result is correct."""
56 handle_style_error = self._mock_style_error_handler 58 handle_style_error = self._mock_style_error_handler
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 checker.check(input_lines) 114 checker.check(input_lines)
113 self.assertEqual(self._error_lines, error_lines) 115 self.assertEqual(self._error_lines, error_lines)
114 116
115 def test_notab(self): 117 def test_notab(self):
116 self.assert_tab([''], []) 118 self.assert_tab([''], [])
117 self.assert_tab(['foo', 'bar'], []) 119 self.assert_tab(['foo', 'bar'], [])
118 120
119 def test_tab(self): 121 def test_tab(self):
120 self.assert_tab(['\tfoo'], [1]) 122 self.assert_tab(['\tfoo'], [1])
121 self.assert_tab(['line1', '\tline2', 'line3\t'], [2, 3]) 123 self.assert_tab(['line1', '\tline2', 'line3\t'], [2, 3])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698