Skip to content

Commit dcfc7f1

Browse files
authored
Merge pull request #120 from mikeywaites/feature/fix-string-cast
fix string casting
2 parents c33a398 + 76f0407 commit dcfc7f1

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.0-rc4
1+
1.0.0-rc5

kim/pipelines/string.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ def is_valid_string(session):
2121
"""
2222

2323
try:
24-
return six.text_type(session.data)
24+
session.data = six.text_type(session.data)
25+
return session.data
2526
except ValueError:
2627
raise session.field.invalid(error_type='type_error')
2728

tests/test_pipelines/test_string.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,13 @@ def test_is_valid_choice():
8888
mapper_session = get_mapper_session(data={'type': 'one'}, output=output)
8989
field.marshal(mapper_session)
9090
assert output == {'type': 'one'}
91+
92+
93+
def test_string_input_cast():
94+
95+
field = String(name='name', required=True)
96+
97+
output = {}
98+
mapper_session = get_mapper_session(data={'name': 123}, output=output)
99+
field.marshal(mapper_session)
100+
assert output == {'name': '123'}

0 commit comments

Comments
 (0)