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

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

Issue 2256793002: Make docstrings more consistent using format-webkitpy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make indentation of final quote based on parse tree (indentation prior to docstring node) rather th… Created 4 years, 3 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 # -*- coding: utf-8; -*- 1 # -*- coding: utf-8; -*-
2 # 2 #
3 # Copyright (C) 2009 Google Inc. All rights reserved. 3 # Copyright (C) 2009 Google Inc. All rights reserved.
4 # Copyright (C) 2009 Torch Mobile Inc. 4 # Copyright (C) 2009 Torch Mobile Inc.
5 # Copyright (C) 2009 Apple Inc. All rights reserved. 5 # Copyright (C) 2009 Apple Inc. All rights reserved.
6 # Copyright (C) 2010 Chris Jerdonek (chris.jerdonek@gmail.com) 6 # Copyright (C) 2010 Chris Jerdonek (chris.jerdonek@gmail.com)
7 # 7 #
8 # Redistribution and use in source and binary forms, with or without 8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are 9 # modification, are permitted provided that the following conditions are
10 # met: 10 # met:
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 from webkitpy.style.filereader import TextFileReader 65 from webkitpy.style.filereader import TextFileReader
66 66
67 67
68 class ConfigureLoggingTestBase(unittest.TestCase): 68 class ConfigureLoggingTestBase(unittest.TestCase):
69 69
70 """Base class for testing configure_logging(). 70 """Base class for testing configure_logging().
71 71
72 Sub-classes should implement: 72 Sub-classes should implement:
73 73
74 is_verbose: The is_verbose value to pass to configure_logging(). 74 is_verbose: The is_verbose value to pass to configure_logging().
75
76 """ 75 """
77 76
78 def setUp(self): 77 def setUp(self):
79 is_verbose = self.is_verbose 78 is_verbose = self.is_verbose
80 79
81 log_stream = TestLogStream(self) 80 log_stream = TestLogStream(self)
82 81
83 # Use a logger other than the root logger or one prefixed with 82 # Use a logger other than the root logger or one prefixed with
84 # webkit so as not to conflict with test-webkitpy logging. 83 # webkit so as not to conflict with test-webkitpy logging.
85 logger = logging.getLogger("unittest") 84 logger = logging.getLogger("unittest")
86 85
87 # Configure the test logger not to pass messages along to the 86 # Configure the test logger not to pass messages along to the
88 # root logger. This prevents test messages from being 87 # root logger. This prevents test messages from being
89 # propagated to loggers used by test-webkitpy logging (e.g. 88 # propagated to loggers used by test-webkitpy logging (e.g.
90 # the root logger). 89 # the root logger).
91 logger.propagate = False 90 logger.propagate = False
92 91
93 self._handlers = configure_logging(stream=log_stream, logger=logger, 92 self._handlers = configure_logging(stream=log_stream, logger=logger,
94 is_verbose=is_verbose) 93 is_verbose=is_verbose)
95 self._log = logger 94 self._log = logger
96 self._log_stream = log_stream 95 self._log_stream = log_stream
97 96
98 def tearDown(self): 97 def tearDown(self):
99 """Reset logging to its original state. 98 """Reset logging to its original state.
100 99
101 This method ensures that the logging configuration set up 100 This method ensures that the logging configuration set up
102 for a unit test does not affect logging in other unit tests. 101 for a unit test does not affect logging in other unit tests.
103
104 """ 102 """
105 logger = self._log 103 logger = self._log
106 for handler in self._handlers: 104 for handler in self._handlers:
107 logger.removeHandler(handler) 105 logger.removeHandler(handler)
108 106
109 def assert_log_messages(self, messages): 107 def assert_log_messages(self, messages):
110 """Assert that the logged messages equal the given messages.""" 108 """Assert that the logged messages equal the given messages."""
111 self._log_stream.assertMessages(messages) 109 self._log_stream.assertMessages(messages)
112 110
113 111
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 expected_messages = ['foo.txt(2): Line contains tab character. ' 624 expected_messages = ['foo.txt(2): Line contains tab character. '
627 '[whitespace/tab] [5]\n'] 625 '[whitespace/tab] [5]\n']
628 self.assertEqual(self._messages, expected_messages) 626 self.assertEqual(self._messages, expected_messages)
629 627
630 628
631 class StyleProcessor_CodeCoverageTest(LoggingTestCase): 629 class StyleProcessor_CodeCoverageTest(LoggingTestCase):
632 630
633 """Test the StyleProcessor class with an emphasis on code coverage. 631 """Test the StyleProcessor class with an emphasis on code coverage.
634 632
635 This class makes heavy use of mock objects. 633 This class makes heavy use of mock objects.
636
637 """ 634 """
638 635
639 class MockDispatchedChecker(object): 636 class MockDispatchedChecker(object):
640 637
641 """A mock checker dispatched by the MockDispatcher.""" 638 """A mock checker dispatched by the MockDispatcher."""
642 639
643 def __init__(self, file_path, min_confidence, style_error_handler): 640 def __init__(self, file_path, min_confidence, style_error_handler):
644 self.file_path = file_path 641 self.file_path = file_path
645 self.min_confidence = min_confidence 642 self.min_confidence = min_confidence
646 self.style_error_handler = style_error_handler 643 self.style_error_handler = style_error_handler
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 """Test that carriage returns aren't stripped from files that are allowe d to contain them.""" 804 """Test that carriage returns aren't stripped from files that are allowe d to contain them."""
808 file_path = 'carriage_returns_allowed.txt' 805 file_path = 'carriage_returns_allowed.txt'
809 lines = ['line1\r', 'line2\r'] 806 lines = ['line1\r', 'line2\r']
810 line_numbers = [100] 807 line_numbers = [100]
811 self._processor.process(lines=lines, 808 self._processor.process(lines=lines,
812 file_path=file_path, 809 file_path=file_path,
813 line_numbers=line_numbers) 810 line_numbers=line_numbers)
814 # The carriage return checker should never have been invoked, and so 811 # The carriage return checker should never have been invoked, and so
815 # should not have saved off any lines. 812 # should not have saved off any lines.
816 self.assertFalse(hasattr(self.carriage_checker, 'lines')) 813 self.assertFalse(hasattr(self.carriage_checker, 'lines'))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698