From 5f45b9b40e76bcd5378d45ed781b5965faf02686 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Sun, 20 Aug 2017 20:43:31 -0400 Subject: [PATCH] Fix pylint and coverage for history. --- qutebrowser/browser/history.py | 2 +- tests/unit/browser/test_history.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/qutebrowser/browser/history.py b/qutebrowser/browser/history.py index e046dc72b..0b3cf108e 100644 --- a/qutebrowser/browser/history.py +++ b/qutebrowser/browser/history.py @@ -48,7 +48,7 @@ class WebHistory(sql.SqlTable): super().__init__("History", ['url', 'title', 'atime', 'redirect'], parent=parent) self.completion = CompletionHistory(parent=self) - if len(self.completion) == 0: + if not self.completion: self._rebuild_completion() self.create_index('HistoryIndex', 'url') self.create_index('HistoryAtimeIndex', 'atime') diff --git a/tests/unit/browser/test_history.py b/tests/unit/browser/test_history.py index ebb8ff206..6fa160d31 100644 --- a/tests/unit/browser/test_history.py +++ b/tests/unit/browser/test_history.py @@ -367,3 +367,13 @@ def test_rebuild_completion(hist): ('example.com/1', '', 2), ('example.com/2 3', '', 3), ] + + +def test_no_rebuild_completion(hist): + """Ensure that completion is not regenerated unless completely empty.""" + hist.add_url(QUrl('example.com/1'), redirect=False, atime=1) + hist.add_url(QUrl('example.com/2'), redirect=False, atime=2) + hist.completion.delete('url', 'example.com/2') + + hist2 = history.WebHistory() + assert list(hist2.completion) == [('example.com/1', '', 1)]