Skip to content

Commit e1edf8b

Browse files
committed
Implement tests for HTTPMethod from Python 3.11
1 parent 589b5dc commit e1edf8b

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

tests/test_decorators.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from http import HTTPMethod
2+
13
import pytest
24
from django.test import TestCase
35

@@ -187,6 +189,17 @@ def test_action(request):
187189

188190
assert str(excinfo.value) == "@action() missing required argument: 'detail'"
189191

192+
def test_method_mapping_http_method(self):
193+
method_names = [getattr(HTTPMethod, name.upper()) for name in APIView.http_method_names]
194+
195+
@action(detail=False, methods=method_names)
196+
def test_action():
197+
raise NotImplementedError
198+
199+
expected_mapping = {name: test_action.__name__ for name in APIView.http_method_names}
200+
201+
assert test_action.mapping == expected_mapping
202+
190203
def test_method_mapping_http_methods(self):
191204
# All HTTP methods should be mappable
192205
@action(detail=False, methods=[])

0 commit comments

Comments
 (0)