fix
This commit is contained in:
@ -17,10 +17,12 @@ if TYPE_CHECKING: # pragma no cover
|
|||||||
from ormar import Model, BaseField
|
from ormar import Model, BaseField
|
||||||
|
|
||||||
|
|
||||||
def to_str(val: Union[bytes, str]):
|
def to_str(val: Union[bytes, str, int]):
|
||||||
""" convert bytes to str simply """
|
""" convert bytes to str simply """
|
||||||
if isinstance(val, bytes):
|
if isinstance(val, bytes):
|
||||||
return val.decode("utf-8")
|
return val.decode("utf-8")
|
||||||
|
elif isinstance(val, str):
|
||||||
|
return val
|
||||||
return str(val)
|
return str(val)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -12,3 +12,4 @@ def test_to_str():
|
|||||||
assert isinstance(expected_bytes, bytes)
|
assert isinstance(expected_bytes, bytes)
|
||||||
|
|
||||||
assert isinstance(to_str(expected_bytes), str)
|
assert isinstance(to_str(expected_bytes), str)
|
||||||
|
assert "1" == to_str(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user