      def __ror__(self, other):
          return OperandHolder(OR, other, self)
  
  
  class OperandHolder(OperationHolderMixin):
      def __init__(self, operator_class, op1_class, op2_class):
          self.operator_class = operator_class
          self.op1_class = op1_class
 
</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):
    def __invert__(self):
        return SingleOperandHolder(NOT, self)


class SingleOperandHolder(OperationHolderMixin):
    def __init__(self, operator_class, op1_class):
        self.operator_class = operator_class
        self.op1_class = op1_class

    def __call__(self, *args, **kwargs):
        op1 = self.op1_class(*args, **kwargs)
        return self.operator_class(op1)

      def __ror__(self, other):
          return OperandHolder(OR, other, self)
  
    def __invert__(self):
        return SingleOperandHolder(NOT, self)


class SingleOperandHolder(OperationHolderMixin):
    def __init__(self, operator_class, op1_class):
        self.operator_class = operator_class
        self.op1_class = op1_class

    def __call__(self, *args, **kwargs):
        op1 = self.op1_class(*args, **kwargs)
        return self.operator_class(op1)

  
  class OperandHolder(OperationHolderMixin):
      def __init__(self, operator_class, op1_class, op2_class):
          self.operator_class = operator_class
          self.op1_class = op1_class
keep keep add keep keep keep keep keep
 Add negation ~ operator to permissions composition (#6361) 
rest_framework/permissions.py