Browse Source

Reformat.

debian-sid
Tom Payne 14 years ago
parent
commit
029685d46e
  1. 34
      test/test_exif.py
  2. 12
      test/test_igc.py
  3. 154
      test/test_util.py

34
test/test_exif.py

@ -1,6 +1,6 @@
#!/usr/bin/python
#
# test/test_igc.py igc2kmz IGC test functions
# test/test_igc.py igc2kmz EXIF test functions
# Copyright (C) 2008 Tom Payne
#
# This program is free software: you can redistribute it and/or modify
@ -29,22 +29,22 @@ import igc2kmz.exif
def main(argv):
for arg in argv[1:]:
try:
if urlparse.urlparse(arg).scheme:
url = arg
else:
url = 'file://' + os.path.realpath(arg)
jpeg = igc2kmz.exif.JPEG(urllib2.urlopen(url))
for tag, value in jpeg.exif.items():
if tag == 'UserComment':
jpeg.exif[tag] = igc2kmz.exif.parse_usercomment(value)
elif isinstance(tag, str) and tag.startswith('DateTime'):
jpeg.exif[tag] = igc2kmz.exif.parse_datetime(value)
pprint.pprint(jpeg.__dict__)
except igc2kmz.exif.SyntaxError, line:
print "%s: %s" % (arg, line)
for arg in argv[1:]:
try:
if urlparse.urlparse(arg).scheme:
url = arg
else:
url = 'file://' + os.path.realpath(arg)
jpeg = igc2kmz.exif.JPEG(urllib2.urlopen(url))
for tag, value in jpeg.exif.items():
if tag == 'UserComment':
jpeg.exif[tag] = igc2kmz.exif.parse_usercomment(value)
elif isinstance(tag, str) and tag.startswith('DateTime'):
jpeg.exif[tag] = igc2kmz.exif.parse_datetime(value)
pprint.pprint(jpeg.__dict__)
except igc2kmz.exif.SyntaxError, line:
print "%s: %s" % (arg, line)
if __name__ == '__main__':
main(sys.argv)
main(sys.argv)

12
test/test_igc.py

@ -26,12 +26,12 @@ import igc2kmz.igc
def main(argv):
for arg in argv[1:]:
try:
igc2kmz.igc.IGC(open(arg))
except igc2kmz.igc.SyntaxError, line:
print "%s: %s" % (arg, line)
for arg in argv[1:]:
try:
igc2kmz.igc.IGC(open(arg))
except igc2kmz.igc.SyntaxError, line:
print "%s: %s" % (arg, line)
if __name__ == '__main__':
main(sys.argv)
main(sys.argv)

154
test/test_util.py

@ -28,126 +28,126 @@ from igc2kmz.util import find_first_ge, salient, runs_where
class TestFindFirstGE(unittest.TestCase):
def test_empty(self):
self.assertEqual(find_first_ge([], 0), None)
def test_empty(self):
self.assertEqual(find_first_ge([], 0), None)
def test_minus1(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], -1), 0)
def test_minus1(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], -1), 0)
def test_0(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 0), 0)
def test_0(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 0), 0)
def test_1(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 1), 1)
def test_1(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 1), 1)
def test_2(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 2), 1)
def test_2(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 2), 1)
def test_3(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 3), 2)
def test_3(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 3), 2)
def test_4(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 4), 2)
def test_4(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 4), 2)
def test_5(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 5), 3)
def test_5(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 5), 3)
def test_6(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 6), 3)
def test_6(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 6), 3)
def test_7(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 7), 4)
def test_7(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 7), 4)
def test_8(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 8), 4)
def test_8(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 8), 4)
def test_9(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 9), None)
def test_9(self):
self.assertEqual(find_first_ge([0, 2, 4, 6, 8], 9), None)
class TestSalient(unittest.TestCase):
def test_empty(self):
self.assertEqual(salient([]), [])
def test_empty(self):
self.assertEqual(salient([]), [])
def test_one(self):
self.assertEqual(salient([0]), [0])
def test_one(self):
self.assertEqual(salient([0]), [0])
def test_2up(self):
self.assertEqual(salient([0, 1]), [0, 1])
def test_2up(self):
self.assertEqual(salient([0, 1]), [0, 1])
def test_2down(self):
self.assertEqual(salient([1, 0]), [0, 1])
def test_2down(self):
self.assertEqual(salient([1, 0]), [0, 1])
def test_2flat(self):
self.assertEqual(salient([0, 0]), [0, 1])
def test_2flat(self):
self.assertEqual(salient([0, 0]), [0, 1])
def test_3up(self):
self.assertEqual(salient([0, 1, 2]), [0, 2])
def test_3up(self):
self.assertEqual(salient([0, 1, 2]), [0, 2])
def test_3down(self):
self.assertEqual(salient([2, 1, 0]), [0, 2])
def test_3down(self):
self.assertEqual(salient([2, 1, 0]), [0, 2])
def test_3flat(self):
self.assertEqual(salient([0, 0, 0]), [0, 2])
def test_3flat(self):
self.assertEqual(salient([0, 0, 0]), [0, 2])
def test_3n(self):
self.assertEqual(salient([0, 1, 0]), [0, 1, 2])
def test_3n(self):
self.assertEqual(salient([0, 1, 0]), [0, 1, 2])
def test_3u(self):
self.assertEqual(salient([1, 0, 1]), [0, 1, 2])
def test_3u(self):
self.assertEqual(salient([1, 0, 1]), [0, 1, 2])
def test_3n_epsilon(self):
self.assertEqual(salient([0, 1, 0], 2), [0, 2])
def test_3n_epsilon(self):
self.assertEqual(salient([0, 1, 0], 2), [0, 2])
def test_3u_epsilon(self):
self.assertEqual(salient([1, 0, 1], 2), [0, 2])
def test_3u_epsilon(self):
self.assertEqual(salient([1, 0, 1], 2), [0, 2])
def test_4up(self):
self.assertEqual(salient([0, 1, 2, 3]), [0, 3])
def test_4up(self):
self.assertEqual(salient([0, 1, 2, 3]), [0, 3])
def test_4down(self):
self.assertEqual(salient([3, 2, 1, 0]), [0, 3])
def test_4down(self):
self.assertEqual(salient([3, 2, 1, 0]), [0, 3])
def test_4flat(self):
self.assertEqual(salient([0, 0, 0, 0]), [0, 3])
def test_4flat(self):
self.assertEqual(salient([0, 0, 0, 0]), [0, 3])
def test_nhump(self):
self.assertEqual(salient([0, 1, 1, 0]), [0, 1, 3])
def test_nhump(self):
self.assertEqual(salient([0, 1, 1, 0]), [0, 1, 3])
def test_uhump(self):
self.assertEqual(salient([1, 0, 0, 1]), [0, 1, 3])
def test_uhump(self):
self.assertEqual(salient([1, 0, 0, 1]), [0, 1, 3])
def test_notch(self):
self.assertEqual(salient([0,1,2,3,3,5,6,7]), [0, 7])
def test_notch(self):
self.assertEqual(salient([0,1,2,3,3,5,6,7]), [0, 7])
def test_complex1(self):
self.assertEqual(salient([0,2,4,6,8,7,6,7,9,7]), [0, 4, 6, 8, 9])
def test_complex1(self):
self.assertEqual(salient([0,2,4,6,8,7,6,7,9,7]), [0, 4, 6, 8, 9])
def test_complex2(self):
self.assertEqual(salient([0,2,4,6,8,7,6,7,8,7], 2), [0, 4, 6, 9])
def test_complex2(self):
self.assertEqual(salient([0,2,4,6,8,7,6,7,8,7], 2), [0, 4, 6, 9])
def test_complex3(self):
self.assertEqual(salient([0,2,4,6,8,7,6,7,8,7], 3), [0, 9])
def test_complex3(self):
self.assertEqual(salient([0,2,4,6,8,7,6,7,8,7], 3), [0, 9])
class TestRunsWhere(unittest.TestCase):
def test_1(self):
self.assertEqual(list(runs_where([])), [])
def test_1(self):
self.assertEqual(list(runs_where([])), [])
def test_2(self):
self.assertEqual(list(runs_where([True])), [slice(0, 1)])
def test_2(self):
self.assertEqual(list(runs_where([True])), [slice(0, 1)])
def test_3(self):
self.assertEqual(list(runs_where([False])), [])
def test_3(self):
self.assertEqual(list(runs_where([False])), [])
def test_4(self):
self.assertEqual(list(runs_where([True, False])), [slice(0, 1)])
def test_4(self):
self.assertEqual(list(runs_where([True, False])), [slice(0, 1)])
def test_5(self):
self.assertEqual(list(runs_where([False, True])), [slice(1, 2)])
def test_5(self):
self.assertEqual(list(runs_where([False, True])), [slice(1, 2)])
if __name__ == '__main__':
unittest.main()
unittest.main()

Loading…
Cancel
Save