mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-24 18:44:00 +03:00
Inherit from faked classes in tests to satisfy mypy (#8859)
* tests: inherit FakeResolverMatcher from django.urls.ResolverMatcher in tests/test_versioning.py * tests: inherit from rest_framework.versioning.BaseVersioning in tests/test_reverse.py * fix: isort --------- Co-authored-by: Piotr Szyma <pszyma@opera.com>
This commit is contained in:
parent
2db0c0bf0a
commit
22d206c1e0
|
@ -3,6 +3,7 @@ from django.urls import NoReverseMatch, path
|
|||
|
||||
from rest_framework.reverse import reverse
|
||||
from rest_framework.test import APIRequestFactory
|
||||
from rest_framework.versioning import BaseVersioning
|
||||
|
||||
factory = APIRequestFactory()
|
||||
|
||||
|
@ -16,7 +17,7 @@ urlpatterns = [
|
|||
]
|
||||
|
||||
|
||||
class MockVersioningScheme:
|
||||
class MockVersioningScheme(BaseVersioning):
|
||||
|
||||
def __init__(self, raise_error=False):
|
||||
self.raise_error = raise_error
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import pytest
|
||||
from django.test import override_settings
|
||||
from django.urls import include, path, re_path
|
||||
from django.urls import ResolverMatch, include, path, re_path
|
||||
|
||||
from rest_framework import serializers, status, versioning
|
||||
from rest_framework.decorators import APIView
|
||||
|
@ -126,7 +126,7 @@ class TestRequestVersion:
|
|||
assert response.data == {'version': None}
|
||||
|
||||
def test_namespace_versioning(self):
|
||||
class FakeResolverMatch:
|
||||
class FakeResolverMatch(ResolverMatch):
|
||||
namespace = 'v1'
|
||||
|
||||
scheme = versioning.NamespaceVersioning
|
||||
|
@ -199,7 +199,7 @@ class TestURLReversing(URLPatternsTestCase, APITestCase):
|
|||
assert response.data == {'url': 'http://testserver/another/'}
|
||||
|
||||
def test_reverse_namespace_versioning(self):
|
||||
class FakeResolverMatch:
|
||||
class FakeResolverMatch(ResolverMatch):
|
||||
namespace = 'v1'
|
||||
|
||||
scheme = versioning.NamespaceVersioning
|
||||
|
@ -250,7 +250,7 @@ class TestInvalidVersion:
|
|||
assert response.status_code == status.HTTP_404_NOT_FOUND
|
||||
|
||||
def test_invalid_namespace_versioning(self):
|
||||
class FakeResolverMatch:
|
||||
class FakeResolverMatch(ResolverMatch):
|
||||
namespace = 'v3'
|
||||
|
||||
scheme = versioning.NamespaceVersioning
|
||||
|
|
Loading…
Reference in New Issue
Block a user