Skip to content

Commit

Permalink
fix set tests after return type change
Browse files Browse the repository at this point in the history
  • Loading branch information
mdumandag committed Nov 29, 2023
1 parent 86bcfe9 commit 6035d60
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 3 additions & 1 deletion tests/commands/set/test_sadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ def test_sadd(redis: Redis):
assert result == 3 # Number of elements added to the set

# Verify that the set contains the added elements
assert redis.smembers(set_name) == {"element1", "element2", "element3"}
members = redis.smembers(set_name)
members.sort()
assert members == ["element1", "element2", "element3"]
6 changes: 1 addition & 5 deletions tests/commands/set/test_sdiffstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,4 @@ def test_sdiffstore(redis: Redis):
expected_result = 1 # Expected number of elements in the destination set
assert result == expected_result

# Get the elements from the destination set
destination_set_elements = redis.smembers(destination_set)

expected_set_elements = {"element1"} # Expected elements in the destination set
assert destination_set_elements == expected_set_elements
assert redis.smembers(destination_set) == ["element1"]
5 changes: 1 addition & 4 deletions tests/commands/set/test_sinterstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,4 @@ def test_sinterstore(redis: Redis):
expected_result = 1 # Number of elements in the resulting set
assert result == expected_result

# Check the elements in the resulting set
result_set_elements = redis.smembers(result_set)
expected_elements = {"element3"} # Expected elements in the resulting set
assert result_set_elements == expected_elements
assert redis.smembers(result_set) == ["element3"]
3 changes: 2 additions & 1 deletion tests/commands/set/test_sunion.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def test_sunion_single_set(redis: Redis):
result = redis.sunion(set1)

# Assert that set1 itself is returned
assert result == {"apple", "banana", "cherry"}
result.sort()
assert result == ["apple", "banana", "cherry"]

with pytest.raises(Exception):
redis.sunion()
10 changes: 7 additions & 3 deletions tests/commands/set/test_sunionstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def test_sunionstore(redis: Redis):
assert result == 4

# Assert that the members in the union set are as expected
assert redis.smembers(union_set) == {"apple", "banana", "cherry", "date"}
members = redis.smembers(union_set)
members.sort()
assert members == ["apple", "banana", "cherry", "date"]


def test_sunionstore_empty_sets(redis: Redis):
Expand All @@ -51,7 +53,7 @@ def test_sunionstore_empty_sets(redis: Redis):
assert result == 0

# Assert that the union set is also empty
assert redis.smembers(union_set) == set()
assert redis.smembers(union_set) == []


def test_sunionstore_single_set(redis: Redis):
Expand All @@ -68,4 +70,6 @@ def test_sunionstore_single_set(redis: Redis):
assert result == 3

# Assert that the members in the union set are the same as set1
assert redis.smembers(union_set) == {"apple", "banana", "cherry"}
members = redis.smembers(union_set)
members.sort()
assert members == ["apple", "banana", "cherry"]

0 comments on commit 6035d60

Please sign in to comment.