Add __eq__ method for permissions.OperandHolder class by janlis-ff · Pull Request #8710 · encode/django-rest-framework (original) (raw)

The reason behind this proposal is to fully enable permission_classes comparison, e.g. in tests:

myapp/views.py

from rest_framework.views import APIView from rest_framework.permissions import IsAdminUser from myapp.permissions import MyPermission

class MyView(APIView): permission_classes = [MyPermission | IsAdminUser] # ...

myapp/tests/views/test_my_view.py

from myapp.views import MyView from rest_framework.permissions import IsAdminUser from myapp.permissions import MyPermission

def test__permission_classes(): cls = MyView assert cls.permission_classes == [MyPermission | IsAdminUser]

I'd love to submit an actual test, but being a first-time contributor here I'm not sure where and how exactly would it fit in just by looking at tests/test_permissions.py.

Have a nice day!