Fix bug in latitude/longitude conversion

Fixed unit test for python3.  int('+ 1') works in python2 but not python3.
Also corrected a unit test.
This commit is contained in:
Nick Hall 2014-05-15 19:02:36 +01:00
parent fb30873888
commit dce7a6d7f7
2 changed files with 7 additions and 4 deletions

View File

@ -116,9 +116,12 @@ def __convert_using_colon_repr(stringValue):
# if no characters before ':' nothing useful is input! # if no characters before ':' nothing useful is input!
if len(l[0]) == 0: if len(l[0]) == 0:
return None return None
if l[0][0] == '-': if l[0][0] in ['+', '-']:
sign = '-' sign = l[0][0]
l[0]=l[0][1:] l[0]=l[0][1:].strip()
# regard a second sign as an error
if l[0][0] in ['+', '-']:
return None
else: else:
sign = '+' sign = '+'
try: try:

View File

@ -202,7 +202,7 @@ class PlaceTest(unittest.TestCase):
self._test_formats_fail(lat, lon) self._test_formats_fail(lat, lon)
lat, lon = '-50:10:1', '-+2:1:2' lat, lon = '-50:10:1', '-+2:1:2'
self._test_formats_success(lat, lon) self._test_formats_fail(lat, lon)
def test_missing_minute(self): def test_missing_minute(self):
lat, lon = '-50::1', '-2:1:2' lat, lon = '-50::1', '-2:1:2'