chore: fix a test which was failing on python 3.9 due to changed python semantics

This commit is contained in:
Umut
2022-08-29 14:43:09 +02:00
parent 05282285a3
commit 847aaae0ab
2 changed files with 5 additions and 2 deletions

View File

@@ -114,17 +114,20 @@ class Configuration:
raise TypeError(f"Unexpected keyword argument '{name}'")
hint = hints[name]
expected = None
is_correctly_typed = True
if name == "insecure_key_cache_location":
if not (value is None or isinstance(value, str)):
is_correctly_typed = False
expected = "Optional[str]"
elif not isinstance(value, hint): # type: ignore
is_correctly_typed = False
if not is_correctly_typed:
expected = hint.__name__ if hasattr(hint, "__name__") else str(hint)
if expected is None:
expected = hint.__name__ if hasattr(hint, "__name__") else str(hint)
raise TypeError(
f"Unexpected type for keyword argument '{name}' "
f"(expected '{expected}', got '{type(value).__name__}')"

View File

@@ -72,7 +72,7 @@ def test_configuration_fork():
{"insecure_key_cache_location": 3},
TypeError,
"Unexpected type for keyword argument 'insecure_key_cache_location' "
"(expected 'typing.Union[str, NoneType]', got 'int')",
"(expected 'Optional[str]', got 'int')",
),
],
)