diff options
author | Arach Tchoupani <arach@lot18.com> | 2012-01-25 20:28:27 -0500 |
---|---|---|
committer | Arach Tchoupani <arach@lot18.com> | 2012-01-25 20:28:27 -0500 |
commit | 16e9aa2b28b7d72e0b699cc126b7d5610dcf7d29 (patch) | |
tree | 6f6c3743b6a256362235a5ff57c73a244908a8b2 /unit_tests | |
parent | 45bd7d506efaecfb06761b836f6b90b8d6b7f5e1 (diff) | |
download | nose-16e9aa2b28b7d72e0b699cc126b7d5610dcf7d29.tar.gz |
add loglevel option to logcapture plugin and add associated test
Diffstat (limited to 'unit_tests')
-rw-r--r-- | unit_tests/test_logcapture_plugin.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/unit_tests/test_logcapture_plugin.py b/unit_tests/test_logcapture_plugin.py index 05f667f..f53f233 100644 --- a/unit_tests/test_logcapture_plugin.py +++ b/unit_tests/test_logcapture_plugin.py @@ -79,6 +79,22 @@ class TestLogCapturePlugin(object): eq_(1, len(c.handler.buffer)) eq_("Hello", c.handler.buffer[0].msg) + def test_loglevel(self): + c = LogCapture() + parser = OptionParser() + c.addOptions(parser, {}) + options, args = parser.parse_args(['--logging-level', 'INFO']) + c.configure(options, Config()) + c.start() + log = logging.getLogger("loglevel") + log.debug("Hello") + log.info("Goodbye") + c.end() + records = c.formatLogRecords() + eq_(1, len(c.handler.buffer)) + eq_("Goodbye", c.handler.buffer[0].msg) + eq_("loglevel: INFO: Goodbye", records[0]) + def test_clears_all_existing_log_handlers(self): c = LogCapture() parser = OptionParser() @@ -102,7 +118,6 @@ class TestLogCapturePlugin(object): c.beforeTest(mktest()) c.end() - if py27: expect = ["<class 'nose.plugins.logcapture.MyMemoryHandler'>"] else: @@ -141,7 +156,7 @@ class TestLogCapturePlugin(object): assert records[0].startswith('foo:'), records[0] assert records[1].startswith('foo.x:'), records[1] assert records[2].startswith('bar.quux:'), records[2] - + def test_logging_filter_exclude(self): env = {'NOSE_LOGFILTER': '-foo,-bar'} c = LogCapture() @@ -159,7 +174,7 @@ class TestLogCapturePlugin(object): eq_(2, len(records)) assert records[0].startswith('foobar.something:'), records[0] assert records[1].startswith('abara:'), records[1] - + def test_logging_filter_exclude_and_include(self): env = {'NOSE_LOGFILTER': 'foo,-foo.bar'} c = LogCapture() |