Skip to content

Commit c7936eb

Browse files
authored
Merge pull request #279 from cwacek/fix/278
tests: Add a test to validate expected behavior on #278
2 parents 4ea8b43 + 0dde416 commit c7936eb

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

python_jsonschema_objects/wrapper_types.py

+2
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ def validate_items(self):
213213
try:
214214
if isinstance(elem, (six.string_types, six.integer_types, float)):
215215
val = typ(elem)
216+
elif isinstance(elem, classbuilder.LiteralValue):
217+
val = typ(elem._value)
216218
else:
217219
val = typ(**util.coerce_for_expansion(elem))
218220
except TypeError as e:

test/test_pytest.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,15 @@ def test_arrays_can_have_reffed_items_of_mixed_type():
169169
builder = pjs.ObjectBuilder(schema)
170170
ns = builder.build_classes()
171171

172-
ns.Test(list=["foo", "bar"])
172+
x = ns.Test(list=["foo", "bar"])
173173
ns.Test(list=[{"bar": "nice"}, "bar"])
174174
with pytest.raises(pjs.ValidationError):
175175
ns.Test(list=[100])
176176

177+
assert x.list == ["foo", "bar"]
178+
x.list.append(ns.Foo("bleh"))
179+
assert x.list == ["foo", "bar", "bleh"]
180+
177181

178182
def test_regression_39():
179183
builder = pjs.ObjectBuilder("test/thing-two.json")

0 commit comments

Comments
 (0)