Fix whitespace/CRLF

This commit is contained in:
Florian Bruhin 2014-05-27 16:24:26 +02:00
parent 0cac061feb
commit 161b2ef7af
2 changed files with 135 additions and 136 deletions

View File

@ -647,7 +647,6 @@ class CommandDispatcher:
else: else:
cur.inspector.show() cur.inspector.show()
@cmdutils.register(instance='mainwindow.tabs.cmd', modes=['insert'], @cmdutils.register(instance='mainwindow.tabs.cmd', modes=['insert'],
hide=True) hide=True)
def open_editor(self): def open_editor(self):

View File

@ -1,135 +1,135 @@
# Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
# #
# This file is part of qutebrowser. # This file is part of qutebrowser.
# #
# qutebrowser is free software: you can redistribute it and/or modify # qutebrowser is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or # the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# qutebrowser is distributed in the hope that it will be useful, # qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>. # along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
"""Tests for qutebrowser.utils.log.""" """Tests for qutebrowser.utils.log."""
import logging import logging
import unittest import unittest
from unittest import TestCase from unittest import TestCase
import qutebrowser.utils.log as log import qutebrowser.utils.log as log
class LogFilterTests(TestCase): class LogFilterTests(TestCase):
"""Tests for LogFilter. """Tests for LogFilter.
Attributes: Attributes:
logger: The logger we use to create records. logger: The logger we use to create records.
""" """
def setUp(self): def setUp(self):
self.logger = logging.getLogger("foo") self.logger = logging.getLogger("foo")
def _make_record(self, name): def _make_record(self, name):
"""Create a bogus logging record with the supplied logger name.""" """Create a bogus logging record with the supplied logger name."""
return self.logger.makeRecord(name, level=logging.DEBUG, fn=None, return self.logger.makeRecord(name, level=logging.DEBUG, fn=None,
lno=0, msg="", args=None, exc_info=None) lno=0, msg="", args=None, exc_info=None)
def test_empty(self): def test_empty(self):
"""Test if an empty filter lets all messages through.""" """Test if an empty filter lets all messages through."""
logfilter = log.LogFilter(None) logfilter = log.LogFilter(None)
record = self._make_record("eggs.bacon.spam") record = self._make_record("eggs.bacon.spam")
self.assertTrue(logfilter.filter(record)) self.assertTrue(logfilter.filter(record))
record = self._make_record("eggs") record = self._make_record("eggs")
self.assertTrue(logfilter.filter(record)) self.assertTrue(logfilter.filter(record))
def test_matching(self): def test_matching(self):
"""Test if a filter lets an exactly matching logrecord through.""" """Test if a filter lets an exactly matching logrecord through."""
logfilter = log.LogFilter(["eggs", "bacon"]) logfilter = log.LogFilter(["eggs", "bacon"])
record = self._make_record("eggs") record = self._make_record("eggs")
self.assertTrue(logfilter.filter(record)) self.assertTrue(logfilter.filter(record))
record = self._make_record("bacon") record = self._make_record("bacon")
self.assertTrue(logfilter.filter(record)) self.assertTrue(logfilter.filter(record))
record = self._make_record("spam") record = self._make_record("spam")
self.assertFalse(logfilter.filter(record)) self.assertFalse(logfilter.filter(record))
logfilter = log.LogFilter(["eggs.bacon"]) logfilter = log.LogFilter(["eggs.bacon"])
record = self._make_record("eggs.bacon") record = self._make_record("eggs.bacon")
self.assertTrue(logfilter.filter(record)) self.assertTrue(logfilter.filter(record))
def test_equal_start(self): def test_equal_start(self):
"""Test if a filter blocks a logger which looks equal but isn't.""" """Test if a filter blocks a logger which looks equal but isn't."""
logfilter = log.LogFilter(["eggs"]) logfilter = log.LogFilter(["eggs"])
record = self._make_record("eggsauce") record = self._make_record("eggsauce")
self.assertFalse(logfilter.filter(record)) self.assertFalse(logfilter.filter(record))
logfilter = log.LogFilter("eggs.bacon") logfilter = log.LogFilter("eggs.bacon")
record = self._make_record("eggs.baconstrips") record = self._make_record("eggs.baconstrips")
self.assertFalse(logfilter.filter(record)) self.assertFalse(logfilter.filter(record))
def test_child(self): def test_child(self):
"""Test if a filter lets through a logger which is a child.""" """Test if a filter lets through a logger which is a child."""
logfilter = log.LogFilter(["eggs.bacon", "spam.ham"]) logfilter = log.LogFilter(["eggs.bacon", "spam.ham"])
record = self._make_record("eggs.bacon.spam") record = self._make_record("eggs.bacon.spam")
self.assertTrue(logfilter.filter(record)) self.assertTrue(logfilter.filter(record))
record = self._make_record("spam.ham.salami") record = self._make_record("spam.ham.salami")
self.assertTrue(logfilter.filter(record)) self.assertTrue(logfilter.filter(record))
class RAMHandlerTests(TestCase): class RAMHandlerTests(TestCase):
"""Tests for RAMHandler. """Tests for RAMHandler.
Attributes: Attributes:
logger: The logger we use to log to the handler. logger: The logger we use to log to the handler.
handler: The RAMHandler we're testing. handler: The RAMHandler we're testing.
old_level: The level the root logger had before executing the test. old_level: The level the root logger had before executing the test.
old_handlers: The handlers the root logger had before executing the old_handlers: The handlers the root logger had before executing the
test. test.
""" """
def setUp(self): def setUp(self):
self.logger = logging.getLogger() self.logger = logging.getLogger()
self.old_level = self.logger.level self.old_level = self.logger.level
self.old_handlers = self.logger.handlers self.old_handlers = self.logger.handlers
self.logger.handlers = [] self.logger.handlers = []
self.logger.setLevel(logging.NOTSET) self.logger.setLevel(logging.NOTSET)
self.handler = log.RAMHandler(capacity=2) self.handler = log.RAMHandler(capacity=2)
self.handler.setLevel(logging.NOTSET) self.handler.setLevel(logging.NOTSET)
self.logger.addHandler(self.handler) self.logger.addHandler(self.handler)
def test_filled(self): def test_filled(self):
"""Test handler with exactly as much records as it can hold.""" """Test handler with exactly as much records as it can hold."""
self.logger.debug("One") self.logger.debug("One")
self.logger.debug("Two") self.logger.debug("Two")
self.assertEqual(len(self.handler.data), 2) self.assertEqual(len(self.handler.data), 2)
self.assertEqual(self.handler.data[0].msg, "One") self.assertEqual(self.handler.data[0].msg, "One")
self.assertEqual(self.handler.data[1].msg, "Two") self.assertEqual(self.handler.data[1].msg, "Two")
def test_overflow(self): def test_overflow(self):
"""Test handler with more records as it can hold.""" """Test handler with more records as it can hold."""
self.logger.debug("One") self.logger.debug("One")
self.logger.debug("Two") self.logger.debug("Two")
self.logger.debug("Three") self.logger.debug("Three")
self.assertEqual(len(self.handler.data), 2) self.assertEqual(len(self.handler.data), 2)
self.assertEqual(self.handler.data[0].msg, "Two") self.assertEqual(self.handler.data[0].msg, "Two")
self.assertEqual(self.handler.data[1].msg, "Three") self.assertEqual(self.handler.data[1].msg, "Three")
def test_dump_log(self): def test_dump_log(self):
"""Test dump_log().""" """Test dump_log()."""
self.logger.debug("One") self.logger.debug("One")
self.logger.debug("Two") self.logger.debug("Two")
self.logger.debug("Three") self.logger.debug("Three")
self.assertEqual(self.handler.dump_log(), "Two\nThree") self.assertEqual(self.handler.dump_log(), "Two\nThree")
def tearDown(self): def tearDown(self):
"""Restore the original root logger level and handlers.""" """Restore the original root logger level and handlers."""
self.logger.level = self.old_level self.logger.level = self.old_level
self.logger.handlers = self.old_handlers self.logger.handlers = self.old_handlers
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()