Skip to content

Commit 977c9c0

Browse files
akarivroll
authored and
roll
committed
Fix bad usage of the strip function (#77)
1 parent bfce923 commit 977c9c0

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

jsontableschema/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.6.4
1+
0.6.5

jsontableschema/types/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ def __init__(self, field=None):
6767
# Set parsed format (fmt feature)
6868
self.__format_main = self.__format
6969
self.__format_fmt = None
70-
if self.__format.startswith('fmt'):
70+
if self.__format.startswith('fmt:'):
7171
self.__format_main = 'fmt'
72-
self.__format_fmt = self.__format.strip('fmt:')
72+
self.__format_fmt = self.__format[4:]
7373

7474
@property
7575
def field(self):

tests/test_types.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,14 @@ def test_date_type_fmt(self):
446446

447447
self.assertEquals(_type.cast(value), date(2014, 6, 10))
448448

449+
def test_date_type_fmt_stripping_bug(self):
450+
451+
value = '2014-06'
452+
self.field['format'] = 'fmt:%Y-%m'
453+
_type = types.DateType(self.field)
454+
455+
self.assertEquals(_type.cast(value), date(2014, 6, 1))
456+
449457
def test_non_iso_date_fails_for_default(self):
450458
value = '01-01-2019'
451459
_type = types.DateType(self.field)

0 commit comments

Comments
 (0)