-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Function smembers returns deepcopy #202
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Can you rather use the .copy
method on the set, for consistency with other places in the code that need to copy the set (the set contains immutable objects, so a deep copy isn't necessary). Can you also add a unit test to catch the original bug.
@bmerry done |
I think that's not the best way to test this. As far as I'm aware Python doesn't guarantee that mutating a sequence while iterating over it will lead to an exception, and even if it did, it's an indirect way of testing that the value returned by smembers is not affected by future redis operations on the set. A more direct test would be to
|
@bmerry It's done. The old test is also left. This is the real situation that has arisen in me. |
Thanks. |
@@ -1488,6 +1488,12 @@ def test_sismember_wrong_type(self): | |||
def test_smembers(self): | |||
self.assertEqual(self.redis.smembers('foo'), set()) | |||
|
|||
def test_smembers_copy(self): | |||
self.redis.sadd('foo', 'member1') | |||
set = self.redis.smembers('foo') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you call this something other than set
, since that's a builtin type.
self.redis.sadd('foo', 'member1') | ||
set = self.redis.smembers('foo') | ||
self.redis.sadd('foo', 'member2') | ||
self.assertNotEqual(set, self.redis.smembers('foo')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rather check that self.assertEqual(value, set(['member1']))
since that's a more specific test.
No description provided.