parent
021c94eece
commit
392fb3e1d7
@ -21,364 +21,331 @@
|
|||||||
|
|
||||||
"""Tests for the NeighborList class."""
|
"""Tests for the NeighborList class."""
|
||||||
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
from qutebrowser.utils import usertypes
|
from qutebrowser.utils import usertypes
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
class InitTests(unittest.TestCase):
|
|
||||||
|
|
||||||
"""Just try to init some neighborlists.
|
class TestInit:
|
||||||
|
|
||||||
Attributes:
|
"""Just try to init some neighborlists."""
|
||||||
nl: The NeighborList we're testing.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def test_empty(self):
|
def test_empty(self):
|
||||||
"""Test constructing an empty NeighborList."""
|
"""Test constructing an empty NeighborList."""
|
||||||
nl = usertypes.NeighborList()
|
nl = usertypes.NeighborList()
|
||||||
self.assertEqual(nl.items, [])
|
assert nl.items == []
|
||||||
|
|
||||||
def test_items(self):
|
def test_items(self):
|
||||||
"""Test constructing an NeighborList with items."""
|
"""Test constructing an NeighborList with items."""
|
||||||
nl = usertypes.NeighborList([1, 2, 3])
|
nl = usertypes.NeighborList([1, 2, 3])
|
||||||
self.assertEqual(nl.items, [1, 2, 3])
|
assert nl.items == [1, 2, 3]
|
||||||
|
|
||||||
def test_len(self):
|
def test_len(self):
|
||||||
"""Test len() on NeighborList."""
|
"""Test len() on NeighborList."""
|
||||||
nl = usertypes.NeighborList([1, 2, 3])
|
nl = usertypes.NeighborList([1, 2, 3])
|
||||||
self.assertEqual(len(nl), 3)
|
assert len(nl) == 3
|
||||||
|
|
||||||
def test_contains(self):
|
def test_contains(self):
|
||||||
"""Test 'in' on NeighborList."""
|
"""Test 'in' on NeighborList."""
|
||||||
nl = usertypes.NeighborList([1, 2, 3])
|
nl = usertypes.NeighborList([1, 2, 3])
|
||||||
self.assertIn(2, nl)
|
assert 2 in nl
|
||||||
self.assertNotIn(4, nl)
|
assert 4 not in nl
|
||||||
|
|
||||||
|
|
||||||
class DefaultTests(unittest.TestCase):
|
class TestDefaultArg:
|
||||||
|
|
||||||
"""Test the default argument.
|
"""Test the default argument."""
|
||||||
|
|
||||||
Attributes:
|
|
||||||
nl: The NeighborList we're testing.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def test_simple(self):
|
def test_simple(self):
|
||||||
"""Test default with a numeric argument."""
|
"""Test default with a numeric argument."""
|
||||||
nl = usertypes.NeighborList([1, 2, 3], default=2)
|
nl = usertypes.NeighborList([1, 2, 3], default=2)
|
||||||
self.assertEqual(nl._idx, 1)
|
assert nl._idx == 1
|
||||||
|
|
||||||
def test_none(self):
|
def test_none(self):
|
||||||
"""Test default 'None'."""
|
"""Test default 'None'."""
|
||||||
nl = usertypes.NeighborList([1, 2, None], default=None)
|
nl = usertypes.NeighborList([1, 2, None], default=None)
|
||||||
self.assertEqual(nl._idx, 2)
|
assert nl._idx == 2
|
||||||
|
|
||||||
def test_unset(self):
|
def test_unset(self):
|
||||||
"""Test unset default value."""
|
"""Test unset default value."""
|
||||||
nl = usertypes.NeighborList([1, 2, 3])
|
nl = usertypes.NeighborList([1, 2, 3])
|
||||||
self.assertIsNone(nl._idx)
|
assert nl._idx is None
|
||||||
|
|
||||||
|
|
||||||
class EmptyTests(unittest.TestCase):
|
class TestEmpty:
|
||||||
|
|
||||||
"""Tests with no items.
|
"""Tests with no items."""
|
||||||
|
|
||||||
Attributes:
|
@pytest.fixture
|
||||||
nl: The NeighborList we're testing.
|
def neighborlist(self):
|
||||||
"""
|
return usertypes.NeighborList()
|
||||||
|
|
||||||
def setUp(self):
|
def test_curitem(self, neighborlist):
|
||||||
self.nl = usertypes.NeighborList()
|
|
||||||
|
|
||||||
def test_curitem(self):
|
|
||||||
"""Test curitem with no item."""
|
"""Test curitem with no item."""
|
||||||
with self.assertRaises(IndexError):
|
with pytest.raises(IndexError):
|
||||||
self.nl.curitem()
|
neighborlist.curitem()
|
||||||
|
|
||||||
def test_firstitem(self):
|
def test_firstitem(self, neighborlist):
|
||||||
"""Test firstitem with no item."""
|
"""Test firstitem with no item."""
|
||||||
with self.assertRaises(IndexError):
|
with pytest.raises(IndexError):
|
||||||
self.nl.firstitem()
|
neighborlist.firstitem()
|
||||||
|
|
||||||
def test_lastitem(self):
|
def test_lastitem(self, neighborlist):
|
||||||
"""Test lastitem with no item."""
|
"""Test lastitem with no item."""
|
||||||
with self.assertRaises(IndexError):
|
with pytest.raises(IndexError):
|
||||||
self.nl.lastitem()
|
neighborlist.lastitem()
|
||||||
|
|
||||||
def test_getitem(self):
|
def test_getitem(self, neighborlist):
|
||||||
"""Test getitem with no item."""
|
"""Test getitem with no item."""
|
||||||
with self.assertRaises(IndexError):
|
with pytest.raises(IndexError):
|
||||||
self.nl.getitem(1)
|
neighborlist.getitem(1)
|
||||||
|
|
||||||
|
|
||||||
class ItemTests(unittest.TestCase):
|
class TestItems:
|
||||||
|
|
||||||
"""Tests with items.
|
"""Tests with items."""
|
||||||
|
|
||||||
Attributes:
|
@pytest.fixture
|
||||||
nl: The NeighborList we're testing.
|
def neighborlist(self):
|
||||||
"""
|
return usertypes.NeighborList([1, 2, 3, 4, 5], default=3)
|
||||||
|
|
||||||
def setUp(self):
|
def test_curitem(self, neighborlist):
|
||||||
self.nl = usertypes.NeighborList([1, 2, 3, 4, 5], default=3)
|
|
||||||
|
|
||||||
def test_curitem(self):
|
|
||||||
"""Test curitem()."""
|
"""Test curitem()."""
|
||||||
self.assertEqual(self.nl._idx, 2)
|
assert neighborlist._idx == 2
|
||||||
self.assertEqual(self.nl.curitem(), 3)
|
assert neighborlist.curitem() == 3
|
||||||
self.assertEqual(self.nl._idx, 2)
|
assert neighborlist._idx == 2
|
||||||
|
|
||||||
def test_nextitem(self):
|
def test_nextitem(self, neighborlist):
|
||||||
"""Test nextitem()."""
|
"""Test nextitem()."""
|
||||||
self.assertEqual(self.nl.nextitem(), 4)
|
assert neighborlist.nextitem() == 4
|
||||||
self.assertEqual(self.nl._idx, 3)
|
assert neighborlist._idx == 3
|
||||||
self.assertEqual(self.nl.nextitem(), 5)
|
assert neighborlist.nextitem() == 5
|
||||||
self.assertEqual(self.nl._idx, 4)
|
assert neighborlist._idx == 4
|
||||||
|
|
||||||
def test_previtem(self):
|
def test_previtem(self, neighborlist):
|
||||||
"""Test previtem()."""
|
"""Test previtem()."""
|
||||||
self.assertEqual(self.nl.previtem(), 2)
|
assert neighborlist.previtem() == 2
|
||||||
self.assertEqual(self.nl._idx, 1)
|
assert neighborlist._idx == 1
|
||||||
self.assertEqual(self.nl.previtem(), 1)
|
assert neighborlist.previtem() == 1
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
|
|
||||||
def test_firstitem(self):
|
def test_firstitem(self, neighborlist):
|
||||||
"""Test firstitem()."""
|
"""Test firstitem()."""
|
||||||
self.assertEqual(self.nl.firstitem(), 1)
|
assert neighborlist.firstitem() == 1
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
|
|
||||||
def test_lastitem(self):
|
def test_lastitem(self, neighborlist):
|
||||||
"""Test lastitem()."""
|
"""Test lastitem()."""
|
||||||
self.assertEqual(self.nl.lastitem(), 5)
|
assert neighborlist.lastitem() == 5
|
||||||
self.assertEqual(self.nl._idx, 4)
|
assert neighborlist._idx == 4
|
||||||
|
|
||||||
def test_reset(self):
|
def test_reset(self, neighborlist):
|
||||||
"""Test reset()."""
|
"""Test reset()."""
|
||||||
self.nl.nextitem()
|
neighborlist.nextitem()
|
||||||
self.assertEqual(self.nl._idx, 3)
|
assert neighborlist._idx == 3
|
||||||
self.nl.reset()
|
neighborlist.reset()
|
||||||
self.assertEqual(self.nl._idx, 2)
|
assert neighborlist._idx == 2
|
||||||
|
|
||||||
def test_getitem(self):
|
def test_getitem(self, neighborlist):
|
||||||
"""Test getitem()."""
|
"""Test getitem()."""
|
||||||
self.assertEqual(self.nl.getitem(2), 5)
|
assert neighborlist.getitem(2) == 5
|
||||||
self.assertEqual(self.nl._idx, 4)
|
assert neighborlist._idx == 4
|
||||||
self.nl.reset()
|
neighborlist.reset()
|
||||||
self.assertEqual(self.nl.getitem(-2), 1)
|
assert neighborlist.getitem(-2) == 1
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
|
|
||||||
|
|
||||||
class OneTests(unittest.TestCase):
|
class TestSingleItem:
|
||||||
|
|
||||||
"""Tests with a list with only one item.
|
"""Tests with a list with only one item."""
|
||||||
|
|
||||||
Attributes:
|
@pytest.fixture
|
||||||
nl: The NeighborList we're testing.
|
def neighborlist(self):
|
||||||
"""
|
return usertypes.NeighborList([1], default=1)
|
||||||
|
|
||||||
def setUp(self):
|
def test_first_wrap(self, neighborlist):
|
||||||
self.nl = usertypes.NeighborList([1], default=1)
|
|
||||||
|
|
||||||
def test_first_wrap(self):
|
|
||||||
"""Test out of bounds previtem() with mode=wrap."""
|
"""Test out of bounds previtem() with mode=wrap."""
|
||||||
self.nl._mode = usertypes.NeighborList.Modes.wrap
|
neighborlist._mode = usertypes.NeighborList.Modes.wrap
|
||||||
self.nl.firstitem()
|
neighborlist.firstitem()
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
self.assertEqual(self.nl.previtem(), 1)
|
assert neighborlist.previtem() == 1
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
|
|
||||||
def test_first_block(self):
|
def test_first_block(self, neighborlist):
|
||||||
"""Test out of bounds previtem() with mode=block."""
|
"""Test out of bounds previtem() with mode=block."""
|
||||||
self.nl._mode = usertypes.NeighborList.Modes.block
|
neighborlist._mode = usertypes.NeighborList.Modes.block
|
||||||
self.nl.firstitem()
|
neighborlist.firstitem()
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
self.assertEqual(self.nl.previtem(), 1)
|
assert neighborlist.previtem() == 1
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
|
|
||||||
def test_first_raise(self):
|
def test_first_raise(self, neighborlist):
|
||||||
"""Test out of bounds previtem() with mode=raise."""
|
"""Test out of bounds previtem() with mode=raise."""
|
||||||
self.nl._mode = usertypes.NeighborList.Modes.exception
|
neighborlist._mode = usertypes.NeighborList.Modes.exception
|
||||||
self.nl.firstitem()
|
neighborlist.firstitem()
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
with self.assertRaises(IndexError):
|
with pytest.raises(IndexError):
|
||||||
self.nl.previtem()
|
neighborlist.previtem()
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
|
|
||||||
def test_last_wrap(self):
|
def test_last_wrap(self, neighborlist):
|
||||||
"""Test out of bounds nextitem() with mode=wrap."""
|
"""Test out of bounds nextitem() with mode=wrap."""
|
||||||
self.nl._mode = usertypes.NeighborList.Modes.wrap
|
neighborlist._mode = usertypes.NeighborList.Modes.wrap
|
||||||
self.nl.lastitem()
|
neighborlist.lastitem()
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
self.assertEqual(self.nl.nextitem(), 1)
|
assert neighborlist.nextitem() == 1
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
|
|
||||||
def test_last_block(self):
|
def test_last_block(self, neighborlist):
|
||||||
"""Test out of bounds nextitem() with mode=block."""
|
"""Test out of bounds nextitem() with mode=block."""
|
||||||
self.nl._mode = usertypes.NeighborList.Modes.block
|
neighborlist._mode = usertypes.NeighborList.Modes.block
|
||||||
self.nl.lastitem()
|
neighborlist.lastitem()
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
self.assertEqual(self.nl.nextitem(), 1)
|
assert neighborlist.nextitem() == 1
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
|
|
||||||
def test_last_raise(self):
|
def test_last_raise(self, neighborlist):
|
||||||
"""Test out of bounds nextitem() with mode=raise."""
|
"""Test out of bounds nextitem() with mode=raise."""
|
||||||
self.nl._mode = usertypes.NeighborList.Modes.exception
|
neighborlist._mode = usertypes.NeighborList.Modes.exception
|
||||||
self.nl.lastitem()
|
neighborlist.lastitem()
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
with self.assertRaises(IndexError):
|
with pytest.raises(IndexError):
|
||||||
self.nl.nextitem()
|
neighborlist.nextitem()
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
|
|
||||||
|
|
||||||
class BlockTests(unittest.TestCase):
|
class TestBlockMode:
|
||||||
|
|
||||||
"""Tests with mode=block.
|
"""Tests with mode=block."""
|
||||||
|
|
||||||
Attributes:
|
@pytest.fixture
|
||||||
nl: The NeighborList we're testing.
|
def neighborlist(self):
|
||||||
"""
|
return usertypes.NeighborList(
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.nl = usertypes.NeighborList(
|
|
||||||
[1, 2, 3, 4, 5], default=3,
|
[1, 2, 3, 4, 5], default=3,
|
||||||
mode=usertypes.NeighborList.Modes.block)
|
mode=usertypes.NeighborList.Modes.block)
|
||||||
|
|
||||||
def test_first(self):
|
def test_first(self, neighborlist):
|
||||||
"""Test out of bounds previtem()."""
|
"""Test out of bounds previtem()."""
|
||||||
self.nl.firstitem()
|
neighborlist.firstitem()
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
self.assertEqual(self.nl.previtem(), 1)
|
assert neighborlist.previtem() == 1
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
|
|
||||||
def test_last(self):
|
def test_last(self, neighborlist):
|
||||||
"""Test out of bounds nextitem()."""
|
"""Test out of bounds nextitem()."""
|
||||||
self.nl.lastitem()
|
neighborlist.lastitem()
|
||||||
self.assertEqual(self.nl._idx, 4)
|
assert neighborlist._idx == 4
|
||||||
self.assertEqual(self.nl.nextitem(), 5)
|
assert neighborlist.nextitem() == 5
|
||||||
self.assertEqual(self.nl._idx, 4)
|
assert neighborlist._idx == 4
|
||||||
|
|
||||||
|
|
||||||
class WrapTests(unittest.TestCase):
|
class TestWrapMode:
|
||||||
|
|
||||||
"""Tests with mode=wrap.
|
"""Tests with mode=wrap."""
|
||||||
|
|
||||||
Attributes:
|
@pytest.fixture
|
||||||
nl: The NeighborList we're testing.
|
def neighborlist(self):
|
||||||
"""
|
return usertypes.NeighborList(
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.nl = usertypes.NeighborList(
|
|
||||||
[1, 2, 3, 4, 5], default=3, mode=usertypes.NeighborList.Modes.wrap)
|
[1, 2, 3, 4, 5], default=3, mode=usertypes.NeighborList.Modes.wrap)
|
||||||
|
|
||||||
def test_first(self):
|
def test_first(self, neighborlist):
|
||||||
"""Test out of bounds previtem()."""
|
"""Test out of bounds previtem()."""
|
||||||
self.nl.firstitem()
|
neighborlist.firstitem()
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
self.assertEqual(self.nl.previtem(), 5)
|
assert neighborlist.previtem() == 5
|
||||||
self.assertEqual(self.nl._idx, 4)
|
assert neighborlist._idx == 4
|
||||||
|
|
||||||
def test_last(self):
|
def test_last(self, neighborlist):
|
||||||
"""Test out of bounds nextitem()."""
|
"""Test out of bounds nextitem()."""
|
||||||
self.nl.lastitem()
|
neighborlist.lastitem()
|
||||||
self.assertEqual(self.nl._idx, 4)
|
assert neighborlist._idx == 4
|
||||||
self.assertEqual(self.nl.nextitem(), 1)
|
assert neighborlist.nextitem() == 1
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
|
|
||||||
|
|
||||||
class RaiseTests(unittest.TestCase):
|
class TestExceptionMode:
|
||||||
|
|
||||||
"""Tests with mode=exception.
|
"""Tests with mode=exception."""
|
||||||
|
|
||||||
Attributes:
|
@pytest.fixture
|
||||||
nl: The NeighborList we're testing.
|
def neighborlist(self):
|
||||||
"""
|
return usertypes.NeighborList(
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.nl = usertypes.NeighborList(
|
|
||||||
[1, 2, 3, 4, 5], default=3,
|
[1, 2, 3, 4, 5], default=3,
|
||||||
mode=usertypes.NeighborList.Modes.exception)
|
mode=usertypes.NeighborList.Modes.exception)
|
||||||
|
|
||||||
def test_first(self):
|
def test_first(self, neighborlist):
|
||||||
"""Test out of bounds previtem()."""
|
"""Test out of bounds previtem()."""
|
||||||
self.nl.firstitem()
|
neighborlist.firstitem()
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
with self.assertRaises(IndexError):
|
with pytest.raises(IndexError):
|
||||||
self.nl.previtem()
|
neighborlist.previtem()
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
|
|
||||||
def test_last(self):
|
def test_last(self, neighborlist):
|
||||||
"""Test out of bounds nextitem()."""
|
"""Test out of bounds nextitem()."""
|
||||||
self.nl.lastitem()
|
neighborlist.lastitem()
|
||||||
self.assertEqual(self.nl._idx, 4)
|
assert neighborlist._idx == 4
|
||||||
with self.assertRaises(IndexError):
|
with pytest.raises(IndexError):
|
||||||
self.nl.nextitem()
|
neighborlist.nextitem()
|
||||||
self.assertEqual(self.nl._idx, 4)
|
assert neighborlist._idx == 4
|
||||||
|
|
||||||
|
|
||||||
class SnapInTests(unittest.TestCase):
|
class TestSnapIn:
|
||||||
|
|
||||||
"""Tests for the fuzzyval/_snap_in features.
|
"""Tests for the fuzzyval/_snap_in features."""
|
||||||
|
|
||||||
Attributes:
|
@pytest.fixture
|
||||||
nl: The NeighborList we're testing.
|
def neighborlist(self):
|
||||||
"""
|
return usertypes.NeighborList([20, 9, 1, 5])
|
||||||
|
|
||||||
def setUp(self):
|
def test_bigger(self, neighborlist):
|
||||||
self.nl = usertypes.NeighborList([20, 9, 1, 5])
|
|
||||||
|
|
||||||
def test_bigger(self):
|
|
||||||
"""Test fuzzyval with snapping to a bigger value."""
|
"""Test fuzzyval with snapping to a bigger value."""
|
||||||
self.nl.fuzzyval = 7
|
neighborlist.fuzzyval = 7
|
||||||
self.assertEqual(self.nl.nextitem(), 9)
|
assert neighborlist.nextitem() == 9
|
||||||
self.assertEqual(self.nl._idx, 1)
|
assert neighborlist._idx == 1
|
||||||
self.assertEqual(self.nl.nextitem(), 1)
|
assert neighborlist.nextitem() == 1
|
||||||
self.assertEqual(self.nl._idx, 2)
|
assert neighborlist._idx == 2
|
||||||
|
|
||||||
def test_smaller(self):
|
def test_smaller(self, neighborlist):
|
||||||
"""Test fuzzyval with snapping to a smaller value."""
|
"""Test fuzzyval with snapping to a smaller value."""
|
||||||
self.nl.fuzzyval = 7
|
neighborlist.fuzzyval = 7
|
||||||
self.assertEqual(self.nl.previtem(), 5)
|
assert neighborlist.previtem() == 5
|
||||||
self.assertEqual(self.nl._idx, 3)
|
assert neighborlist._idx == 3
|
||||||
self.assertEqual(self.nl.previtem(), 1)
|
assert neighborlist.previtem() == 1
|
||||||
self.assertEqual(self.nl._idx, 2)
|
assert neighborlist._idx == 2
|
||||||
|
|
||||||
def test_equal_bigger(self):
|
def test_equal_bigger(self, neighborlist):
|
||||||
"""Test fuzzyval with matching value, snapping to a bigger value."""
|
"""Test fuzzyval with matching value, snapping to a bigger value."""
|
||||||
self.nl.fuzzyval = 20
|
neighborlist.fuzzyval = 20
|
||||||
self.assertEqual(self.nl.nextitem(), 9)
|
assert neighborlist.nextitem() == 9
|
||||||
self.assertEqual(self.nl._idx, 1)
|
assert neighborlist._idx == 1
|
||||||
|
|
||||||
def test_equal_smaller(self):
|
def test_equal_smaller(self, neighborlist):
|
||||||
"""Test fuzzyval with matching value, snapping to a smaller value."""
|
"""Test fuzzyval with matching value, snapping to a smaller value."""
|
||||||
self.nl.fuzzyval = 5
|
neighborlist.fuzzyval = 5
|
||||||
self.assertEqual(self.nl.previtem(), 1)
|
assert neighborlist.previtem() == 1
|
||||||
self.assertEqual(self.nl._idx, 2)
|
assert neighborlist._idx == 2
|
||||||
|
|
||||||
def test_too_big_next(self):
|
def test_too_big_next(self, neighborlist):
|
||||||
"""Test fuzzyval/next with a value bigger than any in the list."""
|
"""Test fuzzyval/next with a value bigger than any in the list."""
|
||||||
self.nl.fuzzyval = 30
|
neighborlist.fuzzyval = 30
|
||||||
self.assertEqual(self.nl.nextitem(), 20)
|
assert neighborlist.nextitem() == 20
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
|
|
||||||
def test_too_big_prev(self):
|
def test_too_big_prev(self, neighborlist):
|
||||||
"""Test fuzzyval/prev with a value bigger than any in the list."""
|
"""Test fuzzyval/prev with a value bigger than any in the list."""
|
||||||
self.nl.fuzzyval = 30
|
neighborlist.fuzzyval = 30
|
||||||
self.assertEqual(self.nl.previtem(), 20)
|
assert neighborlist.previtem() == 20
|
||||||
self.assertEqual(self.nl._idx, 0)
|
assert neighborlist._idx == 0
|
||||||
|
|
||||||
def test_too_small_next(self):
|
def test_too_small_next(self, neighborlist):
|
||||||
"""Test fuzzyval/next with a value smaller than any in the list."""
|
"""Test fuzzyval/next with a value smaller than any in the list."""
|
||||||
self.nl.fuzzyval = 0
|
neighborlist.fuzzyval = 0
|
||||||
self.assertEqual(self.nl.nextitem(), 1)
|
assert neighborlist.nextitem() == 1
|
||||||
self.assertEqual(self.nl._idx, 2)
|
assert neighborlist._idx == 2
|
||||||
|
|
||||||
def test_too_small_prev(self):
|
def test_too_small_prev(self, neighborlist):
|
||||||
"""Test fuzzyval/prev with a value smaller than any in the list."""
|
"""Test fuzzyval/prev with a value smaller than any in the list."""
|
||||||
self.nl.fuzzyval = 0
|
neighborlist.fuzzyval = 0
|
||||||
self.assertEqual(self.nl.previtem(), 1)
|
assert neighborlist.previtem() == 1
|
||||||
self.assertEqual(self.nl._idx, 2)
|
assert neighborlist._idx == 2
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user