def METHOD_NAME(self):
    m = OAuth2TokenMiddleware(self.dummy_get_response)
    auth_headers = {
        "HTTP_AUTHORIZATION": "Bearer " + "tokstr",
    }
    request = self.factory.get("/a-resource", **auth_headers)
    request.user = self.user
    m(request)
    self.assertIs(request.user, self.user)
    request.user = self.anon_user
    m(request)
    self.assertEqual(request.user.pk, self.user.pk)