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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/text_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) 2009 Google Inc. All rights reserved. 1 # Copyright (C) 2009 Google Inc. All rights reserved.
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 are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 15 matching lines...) Expand all
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 """Unit test for text_style.py.""" 29 """Unit test for text_style.py."""
30 30
31 import unittest 31 import unittest
32 32
33 import text as text_style 33 import text as text_style
34 from text import TextChecker 34 from text import TextChecker
35 35
36
36 class TextStyleTestCase(unittest.TestCase): 37 class TextStyleTestCase(unittest.TestCase):
37 """TestCase for text_style.py""" 38 """TestCase for text_style.py"""
38 39
39 def assertNoError(self, lines): 40 def assertNoError(self, lines):
40 """Asserts that the specified lines has no errors.""" 41 """Asserts that the specified lines has no errors."""
41 self.had_error = False 42 self.had_error = False
42 43
43 def error_for_test(line_number, category, confidence, message): 44 def error_for_test(line_number, category, confidence, message):
44 """Records if an error occurs.""" 45 """Records if an error occurs."""
45 self.had_error = True 46 self.had_error = True
46 47
47 text_style.process_file_data('', lines, error_for_test) 48 text_style.process_file_data('', lines, error_for_test)
48 self.assertFalse(self.had_error, '%s should not have any errors.' % line s) 49 self.assertFalse(self.had_error, '%s should not have any errors.' % line s)
49 50
50 def assertError(self, lines, expected_line_number): 51 def assertError(self, lines, expected_line_number):
51 """Asserts that the specified lines has an error.""" 52 """Asserts that the specified lines has an error."""
52 self.had_error = False 53 self.had_error = False
53 54
54 def error_for_test(line_number, category, confidence, message): 55 def error_for_test(line_number, category, confidence, message):
55 """Checks if the expected error occurs.""" 56 """Checks if the expected error occurs."""
56 self.assertEqual(expected_line_number, line_number) 57 self.assertEqual(expected_line_number, line_number)
57 self.assertEqual('whitespace/tab', category) 58 self.assertEqual('whitespace/tab', category)
58 self.had_error = True 59 self.had_error = True
59 60
60 text_style.process_file_data('', lines, error_for_test) 61 text_style.process_file_data('', lines, error_for_test)
61 self.assertTrue(self.had_error, '%s should have an error [whitespace/tab ].' % lines) 62 self.assertTrue(self.had_error, '%s should have an error [whitespace/tab ].' % lines)
62 63
63
64 def test_no_error(self): 64 def test_no_error(self):
65 """Tests for no error cases.""" 65 """Tests for no error cases."""
66 self.assertNoError(['']) 66 self.assertNoError([''])
67 self.assertNoError(['abc def', 'ggg']) 67 self.assertNoError(['abc def', 'ggg'])
68 68
69
70 def test_error(self): 69 def test_error(self):
71 """Tests for error cases.""" 70 """Tests for error cases."""
72 self.assertError(['2009-12-16\tKent Tamura\t<tkent@chromium.org>'], 1) 71 self.assertError(['2009-12-16\tKent Tamura\t<tkent@chromium.org>'], 1)
73 self.assertError(['2009-12-16 Kent Tamura <tkent@chromium.org>', 72 self.assertError(['2009-12-16 Kent Tamura <tkent@chromium.org>',
74 '', 73 '',
75 '\tReviewed by NOBODY.'], 3) 74 '\tReviewed by NOBODY.'], 3)
76 75
77 76
78 class TextCheckerTest(unittest.TestCase): 77 class TextCheckerTest(unittest.TestCase):
79 78
80 """Tests TextChecker class.""" 79 """Tests TextChecker class."""
81 80
82 def mock_handle_style_error(self): 81 def mock_handle_style_error(self):
83 pass 82 pass
84 83
85 def test_init(self): 84 def test_init(self):
86 """Test __init__ constructor.""" 85 """Test __init__ constructor."""
87 checker = TextChecker("foo.txt", self.mock_handle_style_error) 86 checker = TextChecker("foo.txt", self.mock_handle_style_error)
88 self.assertEqual(checker.file_path, "foo.txt") 87 self.assertEqual(checker.file_path, "foo.txt")
89 self.assertEqual(checker.handle_style_error, self.mock_handle_style_erro r) 88 self.assertEqual(checker.handle_style_error, self.mock_handle_style_erro r)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698