def test_distance_nm(self, stdout): locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'], units='nm') locations.verbose = False locations.distance() # Manually convert to string here to workaround Python 2/3 float # formatting differences expect(stdout.getvalue()) == str(13.298957431655218) + '\n'
def test_distance_multi(self, stdout): locations = NumberedPoints(['52.015;-0.221', '52.168;0.040', '51.420;-1.500']) locations.distance() expect(stdout.getvalue()) == ( 'Location 1 to 2 is 24 kilometres\n' 'Location 2 to 3 is 134 kilometres\n' 'Total distance is 159 kilometres\n' )
def test_distance_multi(self, capsys): locations = NumberedPoints(['52.015;-0.221', '52.168;0.040', '51.420;-1.500']) locations.distance() assert capsys.readouterr()[0] == ( 'Location 1 to 2 is 24 kilometres\n' 'Location 2 to 3 is 134 kilometres\n' 'Total distance is 159 kilometres\n' )
def test_distance_sm(self, stdout): locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'], units='sm') locations.distance() expect(stdout.getvalue()) == 'Location 1 to 2 is 15 miles\n'
def test_distance(self, stdout): locations = NumberedPoints(['52.015;-0.221', '52.168;0.040']) locations.distance() expect(stdout.getvalue()) == 'Location 1 to 2 is 24 kilometres\n'
def test_distance(self, units, result, capsys): locations = NumberedPoints(['52.015;-0.221', '52.168;0.040'], units=units) locations.distance() assert capsys.readouterr()[0] == 'Location 1 to 2 is %s\n' % result