Skip to content

Commit

Permalink
Add 2 tests for divisions
Browse files Browse the repository at this point in the history
  • Loading branch information
0x64746b committed May 9, 2014
1 parent f2d49a4 commit 74f0701
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,27 @@ def test_can_parse_simple_elements_containing_timestamps(self):
parsed_element.time,
datetime.fromtimestamp(test_timestamp)
)

def test_can_parse_simple_elements_containing_divisions(self):
# setup test data
dividend = 2342
divisor = 100
test_element = 'char testDivision="{}%2F{}"'.format(dividend, divisor)

# test parsing of division
parsed_element = parser.SIMPLE_ELEMENT.parseString(test_element)

# check result
self.assertEqual(parsed_element.testDivision, dividend / divisor)

def test_can_parse_divisions(self):
# setup test data
dividend = 4223
divisor = 22
test_division = '"{}%2F{}"'.format(dividend, divisor)

# test parsing of division value
parsed_value = parser.DIVISION.parseString(test_division)

# check result
self.assertEqual(parsed_value[0], dividend / divisor)

0 comments on commit 74f0701

Please sign in to comment.