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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/system/logtesting_unittest.py

Issue 2578213005: Use underscores to separate words in filenames in webkitpy. (Closed)
Patch Set: Fix check for attribute in output_capture.py. Created 4 years 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
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import logging
6 import unittest
7
8 from webkitpy.common.system.logtesting import LoggingTestCase, LogTesting, TestL ogStream
9
10
11 class TestLogStreamTest(unittest.TestCase):
12
13 def test_passed_to_stream_handler(self):
14 stream = TestLogStream(self)
15 handler = logging.StreamHandler(stream)
16 logger = logging.getLogger('test.logger')
17 logger.addHandler(handler)
18 logger.setLevel(logging.INFO)
19 logger.info('bar')
20 stream.assertMessages(['bar\n'])
21
22 def test_direct_use(self):
23 stream = TestLogStream(self)
24 stream.write('foo')
25 stream.flush()
26 stream.assertMessages(['foo'])
27
28
29 class LogTestingTest(unittest.TestCase):
30
31 def test_basic(self):
32 log_testing_instance = LogTesting.setUp(self)
33 logger = logging.getLogger('test.logger')
34 logger.info('my message')
35 log_testing_instance.assertMessages(['INFO: my message\n'])
36 # The list of messages is cleared after being checked once.
37 log_testing_instance.assertMessages([])
38
39 def test_log_level_warning(self):
40 log_testing_instance = LogTesting.setUp(self, logging_level=logging.WARN ING)
41 logger = logging.getLogger('test.logger')
42 logger.info('my message')
43 log_testing_instance.assertMessages([])
44
45
46 class LoggingTestCaseTest(LoggingTestCase):
47
48 def test_basic(self):
49 self.example_logging_code()
50 self.assertLog([
51 'INFO: Informative message\n',
52 'WARNING: Warning message\n',
53 ])
54
55 @staticmethod
56 def example_logging_code():
57 logger = logging.getLogger('test.logger')
58 logger.debug('Debugging message')
59 logger.info('Informative message')
60 logger.warning('Warning message')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698