Skip to content
Snippets Groups Projects
Commit 89efe5fa authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

TST(transformers): Extend typecast unittests a little.

parent 4acad651
No related branches found
No related tags found
2 merge requests!217TST: Make NamedTemporaryFiles Windows-compatible,!203New transformer functions for casting types of variables
Pipeline #58383 passed
...@@ -168,20 +168,22 @@ def test_cast_transformer_functions(): ...@@ -168,20 +168,22 @@ def test_cast_transformer_functions():
for val in ("True", "true", "False", "false"): for val in ("True", "true", "False", "false"):
assert type(cast_to_bool(val, {})) == bool assert type(cast_to_bool(val, {})) == bool
if val[1] == "r": if val[1] == "r":
assert cast_to_bool(val, {}) assert cast_to_bool(val, {}) is True
else: else:
assert not cast_to_bool(val, {}) assert cast_to_bool(val, {}) is False
for val_err in ("jaksdlfj", "0", 1): for val_err in ("jaksdlfj", "0", 1):
with pytest.raises(ValueError): with pytest.raises(ValueError):
cast_to_bool(val_err, {}) cast_to_bool(val_err, {})
assert not cast_to_bool(False, {}) assert cast_to_bool(False, {}) is False
assert cast_to_bool(True, {}) assert cast_to_bool(True, {}) is True
assert cast_to_int("24", {}) == 24 assert cast_to_int("24", {}) == 24
assert cast_to_int(24.0, {}) == 24 assert cast_to_int(24.0, {}) == 24
assert cast_to_int(24, {}) == 24 assert cast_to_int(24, {}) == 24
assert cast_to_int("-24", {}) == -24
with pytest.raises(ValueError): with pytest.raises(ValueError):
cast_to_int("24dsf", {}) cast_to_int("24dsf", {})
with pytest.raises(ValueError):
cast_to_int("24.0", {}) == 24 cast_to_int("24.0", {}) == 24
assert cast_to_float("24", {}) == 24.0 assert cast_to_float("24", {}) == 24.0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment