Skip to content

Commit

Permalink
Test parsing of composed dates
Browse files Browse the repository at this point in the history
  • Loading branch information
0x64746b committed May 15, 2014
1 parent c601b4c commit ae35733
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from __future__ import print_function
from __future__ import unicode_literals

from datetime import datetime
from datetime import date, datetime
import unittest

from ctx_parser import date_time
Expand Down Expand Up @@ -49,3 +49,24 @@ def test_can_parse_unset_utc_flags(self):

# check result
self.assertEqual(parsed_elements.inUtc, False)

def test_can_parse_composed_dates(self):
# setup test data
test_date = date(2014, 5, 15)
test_element = """
date {
int day="%(day)s"
int month="%(month)s"
int year="%(year)s"
} #date
""" % {
'day': test_date.day,
'month': test_date.month,
'year': test_date.year,
}

# test parsing of composed date
parsed_element = date_time.COMPOSED_DATE.parseString(test_element)

# check result
self.assertEqual(parsed_element[0], test_date)

0 comments on commit ae35733

Please sign in to comment.