Skip to content

Commit

Permalink
Merge pull request #264 from marmida/master
Browse files Browse the repository at this point in the history
Fix #263: provide missing format calls for exception messages. Thanks @marmida
  • Loading branch information
andrewelkins committed Nov 20, 2015
2 parents afec830 + cffc145 commit ec96b0b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions arrow/arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,8 @@ def _get_tzinfo(tz_expr):
try:
return parser.TzinfoParser.parse(tz_expr)
except parser.ParserError:
raise ValueError('\'{0}\' not recognized as a timezone')
raise ValueError('\'{0}\' not recognized as a timezone'.format(
tz_expr))

@classmethod
def _get_datetime(cls, expr):
Expand All @@ -854,7 +855,8 @@ def _get_datetime(cls, expr):
expr = float(expr)
return cls.utcfromtimestamp(expr).datetime
except:
raise ValueError('\'{0}\' not recognized as a timestamp or datetime')
raise ValueError(
'\'{0}\' not recognized as a timestamp or datetime'.format(expr))

@classmethod
def _get_frames(cls, name):
Expand Down
6 changes: 4 additions & 2 deletions tests/arrow_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1108,15 +1108,17 @@ def test_get_datetime(self):
assertEqual(get_datetime(dt), dt)
assertEqual(get_datetime(timestamp), arrow.Arrow.utcfromtimestamp(timestamp).datetime)

with assertRaises(ValueError):
with assertRaises(ValueError) as raise_ctx:
get_datetime('abc')
assertFalse('{0}' in raise_ctx.exception.message)

def test_get_tzinfo(self):

get_tzinfo = arrow.Arrow._get_tzinfo

with assertRaises(ValueError):
with assertRaises(ValueError) as raise_ctx:
get_tzinfo('abc')
assertFalse('{0}' in raise_ctx.exception.message)

def test_get_timestamp_from_input(self):

Expand Down

0 comments on commit ec96b0b

Please sign in to comment.