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_init(self):
set_ = RedisSet()
assert set_ == set()
def test_difference_update_with_range_and_set(self):
ramanujans_friends = RedisSet()
ramanujans_friends.difference_update(range(4), {6, 7, 8, 9})
assert ramanujans_friends == set()
ramanujans_friends = RedisSet(range(10))
ramanujans_friends.difference_update(range(4), {6, 7, 8, 9})
assert ramanujans_friends == {4, 5}
def test_issubset(self):
a = RedisSet('abc')
b = RedisSet('abc')
# assert a.issubset(b)
# assert b.issubset(a)
assert a <= b
assert b <= a
assert not a < b
assert not b < a
c = RedisSet('abcd')
# assert a.issubset(c)
# assert not c.issubset(a)
assert a <= c
assert not c <= a
assert a < c
assert not c < a
d = RedisSet('def')
# assert not a.issubset(d)
# assert not d.issubset(a)
assert not a <= d
assert not d <= a
assert not a < d
assert not d < a
def test_repr(self):
basket = RedisSet({'apple'})
assert repr(basket) == "RedisSet{'apple'}"
basket = RedisSet({'apple', 'orange'})
assert repr(basket) in {
"RedisSet{'apple', 'orange'}",
"RedisSet{'orange', 'apple'}",
}
def test_update_with_range(self):
ramanujans_friends = RedisSet()
ramanujans_friends.update(range(10))
assert ramanujans_friends == {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
def test_difference_update_with_empty_set(self):
ramanujans_friends = RedisSet()
ramanujans_friends.difference_update(set())
assert ramanujans_friends == set()
ramanujans_friends = RedisSet(range(10))
ramanujans_friends.difference_update(set())
assert ramanujans_friends == {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
def test_keyexistserror(self):
fruits = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
basket = RedisSet(fruits, key='pottery:basket')
basket # Workaround for Pyflakes. :-(
with self.assertRaises(KeyExistsError):
RedisSet(fruits, key='pottery:basket')
def test_remove(self):
basket = RedisSet({'apple', 'orange'})
basket.remove('orange')
assert basket == {'apple'}
basket.remove('apple')
assert basket == set()
with self.assertRaises(KeyError):
basket.remove('apple')
def test_update_with_no_arguments(self):
s = RedisSet()
s.update()
assert s == set()
s = RedisSet('abcd')
s.update()
assert s == {'a', 'b', 'c', 'd'}
def test_issuperset(self):
a = RedisSet('abc')
b = RedisSet('abc')
# assert a.issuperset(b)
# assert b.issuperset(a)
assert a >= b
assert b >= a
assert not a > b
assert not b > a
c = RedisSet('abcd')
# assert not a.issuperset(c)
# assert c.issuperset(a)
assert not a >= c
assert c >= a
assert not a > c
assert c > a
d = RedisSet('def')
# assert not a.issuperset(d)