      @unittest.skipUnless(oauth2_provider, 'django-oauth2-provider not installed')
      def test_post_form_with_invalid_scope_failing_auth(self):
          """Ensure POSTing with a readonly scope instead of a write scope fails"""
          read_only_access_token = self.access_token
          read_only_access_token.scope = oauth2_provider.scope.SCOPE_NAME_DICT['read']
          read_only_access_token.save()
          auth = self._create_authorization_header(token=read_only_access_token.token)
          response = self.csrf_client.get('/oauth2-with-scope-test/', HTTP_AUTHORIZATION=auth)
          self.assertEqual(response.status_code, 200)
          response = self.csrf_client.post('/oauth2-with-scope-test/', HTTP_AUTHORIZATION=auth)
 
</s> remove         read_write_access_token.scope = oauth2_provider.scope.SCOPE_NAME_DICT['write']
 </s> add         read_write_access_token.scope = oauth2_provider_scope.SCOPE_NAME_DICT['write'] </s> remove             required = oauth2_provider.constants.READ if read_only else oauth2_provider.constants.WRITE
            return oauth2_provider.scope.check(required, request.auth.scope)
 </s> add             required = oauth2_constants.READ if read_only else oauth2_constants.WRITE
            return oauth2_provider_scope.check(required, request.auth.scope) </s> remove from rest_framework.compat import (get_model_name, oauth2_provider)
 </s> add from rest_framework.compat import (get_model_name, oauth2_provider_scope,
                                   oauth2_constants)
        read_only_access_token.scope = oauth2_provider_scope.SCOPE_NAME_DICT['read']
      @unittest.skipUnless(oauth2_provider, 'django-oauth2-provider not installed')
      def test_post_form_with_invalid_scope_failing_auth(self):
          """Ensure POSTing with a readonly scope instead of a write scope fails"""
          read_only_access_token = self.access_token
        read_only_access_token.scope = oauth2_provider_scope.SCOPE_NAME_DICT['read']
          read_only_access_token.save()
          auth = self._create_authorization_header(token=read_only_access_token.token)
          response = self.csrf_client.get('/oauth2-with-scope-test/', HTTP_AUTHORIZATION=auth)
          self.assertEqual(response.status_code, 200)
          response = self.csrf_client.post('/oauth2-with-scope-test/', HTTP_AUTHORIZATION=auth)
keep keep keep keep replace keep keep keep keep keep
 it's safe to import scope and constants 
rest_framework/tests/test_authentication.py