

def test_require_safe_accepts_only_safe_methods(self):
    '\n        Test for the require_safe decorator.\n        A view returns either a response or an exception.\n        Refs #15637.\n        '

    def my_view(request):
        return HttpResponse('OK')
    my_safe_view = require_safe(my_view)
    request = HttpRequest()
    self.method = 'GET'
    self.assertIsInstance(my_safe_view(request), HttpResponse)
    request.method = 'HEAD'
    self.assertIsInstance(my_safe_view(request), HttpResponse)
    request.method = 'POST'
    self.assertIsInstance(my_safe_view(request), HttpResponseNotAllowed)
    request.method = 'PUT'
    self.assertIsInstance(my_safe_view(request), HttpResponseNotAllowed)
    request.method = 'DELETE'
    self.assertIsInstance(my_safe_view(request), HttpResponseNotAllowed)

dataset/ETHPy150Open django/django/tests/decorators/tests.py DecoratorsTest.test_require_safe_accepts_only_safe_methods/VarMisuse@41/107 `request`->`self`