              self.op2.has_object_permission(request, view, obj)
          )
  
  
  class BasePermissionMetaclass(OperationHolderMixin, type):
      pass
  
  
  @six.add_metaclass(BasePermissionMetaclass)
 
</s> remove     def test_several_levels(self):
 </s> add     def test_not_false(self):
        request = factory.get('/1', format='json')
        request.user = AnonymousUser()
        composed_perm = ~permissions.IsAuthenticated
        assert composed_perm().has_permission(request, None) is True

    def test_not_true(self):
        request = factory.get('/1', format='json')
        request.user = self.user
        composed_perm = ~permissions.AllowAny
        assert composed_perm().has_permission(request, None) is False

    def test_several_levels_without_negation(self):
class NOT:
    def __init__(self, op1):
        self.op1 = op1

    def has_permission(self, request, view):
        return not self.op1.has_permission(request, view)

    def has_object_permission(self, request, view, obj):
        return not self.op1.has_object_permission(request, view, obj)


              self.op2.has_object_permission(request, view, obj)
          )
  
  
class NOT:
    def __init__(self, op1):
        self.op1 = op1

    def has_permission(self, request, view):
        return not self.op1.has_permission(request, view)

    def has_object_permission(self, request, view, obj):
        return not self.op1.has_object_permission(request, view, obj)


  class BasePermissionMetaclass(OperationHolderMixin, type):
      pass
  
  
  @six.add_metaclass(BasePermissionMetaclass)
keep keep keep add keep keep keep keep keep
 Add negation ~ operator to permissions composition (#6361) 
rest_framework/permissions.py