-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Provide tests for hashing of OperandHolder
#9437
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
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.
thanks for the followup contribution!
@@ -716,3 +716,59 @@ def has_object_permission(self, request, view, obj): | |||
composed_perm = (IsAuthenticatedUserOwner | permissions.IsAdminUser) | |||
hasperm = composed_perm().has_object_permission(request, None, None) | |||
assert hasperm is False | |||
|
|||
def test_operand_holder_is_hashable(self): | |||
assert hash((permissions.IsAuthenticated & permissions.IsAdminUser)) |
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.
May fail if hash
returns zero. The proper check would be that no exception is thrown. (E.g., via >= 0
)
filtered_permissions = [ | ||
perm for perm | ||
in dict.fromkeys(unfiltered_permissions) | ||
] |
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.
filtered_permissions = list(dict.fromkeys(unfiltered_permissions))
@peterthomassen Should I open PR for these fixes? |
I don't think so; just trying to enable the community to learn from each other! :-) Thanks for the tests, I like how they are set up. |
Description
Provide tests for #9417 according to comment