Improve NeighborList tests.

This commit is contained in:
Florian Bruhin 2015-05-19 18:01:58 +02:00
parent 2643975c3c
commit 4e0d00098c
2 changed files with 12 additions and 1 deletions

View File

@ -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

View File

@ -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: