Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inherit from faked classes in tests to satisfy mypy #8859

Merged
merged 3 commits into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/test_reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from rest_framework.reverse import reverse
from rest_framework.test import APIRequestFactory
from rest_framework.versioning import BaseVersioning

factory = APIRequestFactory()

Expand All @@ -16,7 +17,7 @@ def null_view(request):
]


class MockVersioningScheme:
class MockVersioningScheme(BaseVersioning):

def __init__(self, raise_error=False):
self.raise_error = raise_error
Expand Down
8 changes: 4 additions & 4 deletions tests/test_versioning.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -126,7 +126,7 @@ def test_url_path_versioning(self):
assert response.data == {'version': None}

def test_namespace_versioning(self):
class FakeResolverMatch:
class FakeResolverMatch(ResolverMatch):
namespace = 'v1'

scheme = versioning.NamespaceVersioning
Expand Down Expand Up @@ -199,7 +199,7 @@ def test_reverse_url_path_versioning(self):
assert response.data == {'url': 'http://testserver/another/'}

def test_reverse_namespace_versioning(self):
class FakeResolverMatch:
class FakeResolverMatch(ResolverMatch):
namespace = 'v1'

scheme = versioning.NamespaceVersioning
Expand Down Expand Up @@ -250,7 +250,7 @@ def test_invalid_url_path_versioning(self):
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
Expand Down