Skip to content

Commit

Permalink
Fix bad usage of the strip function
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Jul 11, 2016
1 parent bfce923 commit c3020e4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion jsontableschema/VERSION
@@ -1 +1 @@
0.6.4
0.6.5
4 changes: 2 additions & 2 deletions jsontableschema/types/base.py
Expand Up @@ -67,9 +67,9 @@ def __init__(self, field=None):
# Set parsed format (fmt feature)
self.__format_main = self.__format
self.__format_fmt = None
if self.__format.startswith('fmt'):
if self.__format.startswith('fmt:'):
self.__format_main = 'fmt'
self.__format_fmt = self.__format.strip('fmt:')
self.__format_fmt = self.__format[4:]

@property
def field(self):
Expand Down
8 changes: 8 additions & 0 deletions tests/test_types.py
Expand Up @@ -446,6 +446,14 @@ def test_date_type_fmt(self):

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

def test_date_type_fmt_stripping_bug(self):

value = '2014-06'
self.field['format'] = 'fmt:%Y-%m'
_type = types.DateType(self.field)

self.assertEquals(_type.cast(value), date(2014, 6, 1))

def test_non_iso_date_fails_for_default(self):
value = '01-01-2019'
_type = types.DateType(self.field)
Expand Down

0 comments on commit c3020e4

Please sign in to comment.