mirror of
https://github.com/Steffo99/cfig.git
synced 2024-11-22 07:54:21 +00:00
🧪 Fix tests failing due to a error in the config
This commit is contained in:
parent
809cf435fb
commit
cd7661e536
1 changed files with 9 additions and 4 deletions
|
@ -2,6 +2,7 @@ import pytest
|
||||||
import cfig
|
import cfig
|
||||||
import os
|
import os
|
||||||
import lazy_object_proxy
|
import lazy_object_proxy
|
||||||
|
import typing as t
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import click
|
import click
|
||||||
|
@ -27,7 +28,7 @@ class TestConfig:
|
||||||
"""The first number to sum."""
|
"""The first number to sum."""
|
||||||
try:
|
try:
|
||||||
return int(val)
|
return int(val)
|
||||||
except ValueError:
|
except (ValueError, TypeError):
|
||||||
raise cfig.InvalidValueError("Not an int.")
|
raise cfig.InvalidValueError("Not an int.")
|
||||||
|
|
||||||
assert isinstance(FIRST_NUMBER, lazy_object_proxy.Proxy)
|
assert isinstance(FIRST_NUMBER, lazy_object_proxy.Proxy)
|
||||||
|
@ -38,11 +39,13 @@ class TestConfig:
|
||||||
|
|
||||||
def test_registration_optional(self, basic_config):
|
def test_registration_optional(self, basic_config):
|
||||||
@basic_config.optional()
|
@basic_config.optional()
|
||||||
def SECOND_NUMBER(val: str) -> int:
|
def SECOND_NUMBER(val: t.Optional[str]) -> t.Optional[int]:
|
||||||
"""The second number to sum."""
|
"""The second number to sum."""
|
||||||
|
if val is None:
|
||||||
|
return None
|
||||||
try:
|
try:
|
||||||
return int(val)
|
return int(val)
|
||||||
except ValueError:
|
except (ValueError, TypeError):
|
||||||
raise cfig.InvalidValueError("Not an int.")
|
raise cfig.InvalidValueError("Not an int.")
|
||||||
|
|
||||||
assert isinstance(SECOND_NUMBER, lazy_object_proxy.Proxy)
|
assert isinstance(SECOND_NUMBER, lazy_object_proxy.Proxy)
|
||||||
|
@ -62,8 +65,10 @@ class TestConfig:
|
||||||
raise cfig.InvalidValueError("Not an int.")
|
raise cfig.InvalidValueError("Not an int.")
|
||||||
|
|
||||||
@basic_config.optional()
|
@basic_config.optional()
|
||||||
def SECOND_NUMBER(val: str) -> int:
|
def SECOND_NUMBER(val: t.Optional[str]) -> t.Optional[int]:
|
||||||
"""The second number to sum."""
|
"""The second number to sum."""
|
||||||
|
if val is None:
|
||||||
|
return None
|
||||||
try:
|
try:
|
||||||
return int(val)
|
return int(val)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
|
|
Loading…
Reference in a new issue