From 4e0d00098c6f1c1119d4e5c737f3a89c876eab11 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 19 May 2015 18:01:58 +0200 Subject: [PATCH] Improve NeighborList tests. --- qutebrowser/utils/usertypes.py | 2 +- tests/utils/usertypes/test_neighborlist.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/qutebrowser/utils/usertypes.py b/qutebrowser/utils/usertypes.py index 5a9ca4ad1..d1d6883a8 100644 --- a/qutebrowser/utils/usertypes.py +++ b/qutebrowser/utils/usertypes.py @@ -147,7 +147,7 @@ class NeighborList(collections.abc.Sequence): self._idx += offset self._idx %= len(self.items) new = self.curitem() - elif self._mode == self.Modes.exception: + elif self._mode == self.Modes.exception: # pragma: no branch raise else: self._idx += offset diff --git a/tests/utils/usertypes/test_neighborlist.py b/tests/utils/usertypes/test_neighborlist.py index 41e4f547a..ffce4723e 100644 --- a/tests/utils/usertypes/test_neighborlist.py +++ b/tests/utils/usertypes/test_neighborlist.py @@ -51,6 +51,11 @@ class TestInit: assert 2 in nl assert 4 not in nl + def test_invalid_mode(self): + """Test with an invalid mode.""" + with pytest.raises(TypeError): + usertypes.NeighborList(mode='blah') + class TestDefaultArg: @@ -71,6 +76,12 @@ class TestDefaultArg: nl = usertypes.NeighborList([1, 2, 3]) assert nl._idx is None + def test_invalid_reset(self): + """Test reset without default.""" + nl = usertypes.NeighborList([1, 2, 3, 4, 5]) + with pytest.raises(ValueError): + nl.reset() + class TestEmpty: