Skip to content

Commit

Permalink
fix test coverage regression
Browse files Browse the repository at this point in the history
  • Loading branch information
tfranzel committed Sep 19, 2021
1 parent 5890bd6 commit e9a435c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions tests/test_plumbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

from drf_spectacular.openapi import AutoSchema
from drf_spectacular.plumbing import (
analyze_named_regex_pattern, detype_pattern, follow_field_source, force_instance, is_field,
is_serializer, resolve_type_hint,
analyze_named_regex_pattern, build_basic_type, detype_pattern, follow_field_source,
force_instance, is_field, is_serializer, resolve_type_hint,
)
from drf_spectacular.validation import validate_schema
from tests import generate_schema
Expand Down Expand Up @@ -244,3 +244,8 @@ class XView(generics.RetrieveAPIView):
def test_analyze_named_regex_pattern(no_warnings, pattern, output):
re.compile(pattern) # check validity of regex
assert analyze_named_regex_pattern(pattern) == output


def test_unknown_basic_type(capsys):
build_basic_type(object)
assert 'could not resolve type for "<class \'object\'>' in capsys.readouterr().err
3 changes: 2 additions & 1 deletion tests/test_postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def partial_update(self, request):
assert '/XFooEnum' in components['PatchedXRequest']['properties']['foo']['$ref']


def test_enum_override_variations(no_warnings, clear_caches):
def test_enum_override_variations(no_warnings):
enum_override_variations = ['language_list', 'LanguageEnum']
if DJANGO_VERSION > '3':
enum_override_variations += ['LanguageChoices', 'LanguageChoices.choices']
Expand All @@ -183,6 +183,7 @@ def test_enum_override_variations(no_warnings, clear_caches):
'drf_spectacular.settings.spectacular_settings.ENUM_NAME_OVERRIDES',
{'LanguageEnum': f'tests.test_postprocessing.{variation}'}
):
load_enum_name_overrides.cache_clear()
assert list_hash(['en']) in load_enum_name_overrides()


Expand Down

0 comments on commit e9a435c

Please sign in to comment.