Skip to content

Commit 5e77f09

Browse files
authored
Merge pull request #119 from mikeywaites/feature/fix-int-cast
fix int casting
2 parents 7a5323d + 686885b commit 5e77f09

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

VERSION

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

kim/pipelines/numeric.py

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

2323
try:
24-
return int(session.data)
24+
session.data = int(session.data)
2525
except TypeError:
2626
raise session.field.invalid(error_type='type_error')
2727
except ValueError:
2828
raise session.field.invalid(error_type='type_error')
29+
return session.data
2930

3031

3132
@pipe()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class PyTest(TestCommand):
3636

3737
def finalize_options(self):
3838
TestCommand.finalize_options(self)
39-
self.test_args = ['-x', '-s']
39+
self.test_args = ['-s']
4040
self.test_suite = True
4141

4242
def run_tests(self):

tests/test_pipelines/test_numeric.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ def test_integer_input():
4646
field.marshal(mapper_session)
4747
assert output == {'name': 2}
4848

49+
output = {}
50+
mapper_session = get_mapper_session(
51+
data={'name': '2', 'email': 'mike@mike.com'}, output=output)
52+
field.marshal(mapper_session)
53+
assert output == {'name': 2}
54+
4955

5056
def test_integer_field_invalid_type():
5157

@@ -122,6 +128,10 @@ def test_min_max():
122128
field.marshal(mapper_session)
123129
assert output == {'age': 25}
124130

131+
mapper_session = get_mapper_session(data={'age': '25'}, output=output)
132+
field.marshal(mapper_session)
133+
assert output == {'age': 25}
134+
125135

126136
def test_is_valid_decimal_pipe():
127137
"""test piping data through is_valid_decimal.

0 commit comments

Comments
 (0)