Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_repr(self):
d = RedisDeque()
assert repr(d) == 'RedisDeque([])'
d = RedisDeque('ghi')
assert repr(d) == "RedisDeque(['g', 'h', 'i'])"
d = RedisDeque(maxlen=2)
assert repr(d) == 'RedisDeque([], maxlen=2)'
d = RedisDeque('ghi', maxlen=2)
assert repr(d) == "RedisDeque(['h', 'i'], maxlen=2)"
def test_rotate_zero_steps(self):
d = RedisDeque(('g', 'h', 'i', 'j', 'k', 'l'))
d.rotate(0)
assert d == ['g', 'h', 'i', 'j', 'k', 'l']
def test_append_trims_when_full(self):
d = RedisDeque('gh', maxlen=3)
d.append('i')
assert d == ['g', 'h', 'i']
d.append('j')
assert d == ['h', 'i', 'j']
d.appendleft('g')
assert d == ['g', 'h', 'i']
def test_repr(self):
d = RedisDeque()
assert repr(d) == 'RedisDeque([])'
d = RedisDeque('ghi')
assert repr(d) == "RedisDeque(['g', 'h', 'i'])"
d = RedisDeque(maxlen=2)
assert repr(d) == 'RedisDeque([], maxlen=2)'
d = RedisDeque('ghi', maxlen=2)
assert repr(d) == "RedisDeque(['h', 'i'], maxlen=2)"
def test_repr(self):
d = RedisDeque()
assert repr(d) == 'RedisDeque([])'
d = RedisDeque('ghi')
assert repr(d) == "RedisDeque(['g', 'h', 'i'])"
d = RedisDeque(maxlen=2)
assert repr(d) == 'RedisDeque([], maxlen=2)'
d = RedisDeque('ghi', maxlen=2)
assert repr(d) == "RedisDeque(['h', 'i'], maxlen=2)"
def test_repr(self):
d = RedisDeque()
assert repr(d) == 'RedisDeque([])'
d = RedisDeque('ghi')
assert repr(d) == "RedisDeque(['g', 'h', 'i'])"
d = RedisDeque(maxlen=2)
assert repr(d) == 'RedisDeque([], maxlen=2)'
d = RedisDeque('ghi', maxlen=2)
assert repr(d) == "RedisDeque(['h', 'i'], maxlen=2)"
def test_persistent_deque_bigger_than_maxlen(self):
d1 = RedisDeque('ghi')
d1 # Workaround for Pyflakes. :-(
with self.assertRaises(IndexError):
RedisDeque(key=d1.key, maxlen=0)
def test_insert_into_full(self):
d = RedisDeque('gh', maxlen=3)
d.insert(len(d), 'i')
assert d == ['g', 'h', 'i']
with self.assertRaises(IndexError):
d.insert(len(d), 'j')
def test_extend(self):
d = RedisDeque('ghi', maxlen=4)
d.extend('jkl')
assert d == ['i', 'j', 'k', 'l']
d.extendleft('hg')
assert d == ['g', 'h', 'i', 'j']
def test_persistent_deque_bigger_than_maxlen(self):
d1 = RedisDeque('ghi')
d1 # Workaround for Pyflakes. :-(
with self.assertRaises(IndexError):
RedisDeque(key=d1.key, maxlen=0)