Skip to content

Commit deffa41

Browse files
ksekouvangheem
authored andcommitted
Array from comma single value (#1)
1 parent d2b09c6 commit deffa41

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
1.0.4 (unreleased)
22
------------------
3-
4-
- Nothing changed yet.
3+
- Update serialize to support single item in array
54

65

76
1.0.3 (2019-09-29)

enviral/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def serialize(
122122
logger.warning(
123123
f"Error attempting to load {key} with value {value}"
124124
)
125-
elif schema_type == "array" and "," in value:
125+
elif schema_type == "array":
126126
value = [v.strip() for v in value.split(",")]
127127
if schema_type == "boolean":
128128
value = value.lower() in ("1", "y", "yes", "true")

tests/test_serialize.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,14 @@ def test_array_from_comma_values(env):
106106
}
107107
)
108108
assert settings == {"foo": ["foo", "bar"]}
109+
110+
111+
def test_array_from_comma_single_value(env):
112+
os.environ["FOO"] = "foo"
113+
settings = enviral.serialize(
114+
{
115+
"type": "object",
116+
"properties": {"foo": {"type": "array", "items": {"type": "string"}}},
117+
}
118+
)
119+
assert settings == {"foo": ["foo"]}

0 commit comments

Comments
 (0)