Skip to content

Commit 32e46a4

Browse files
Cast set_location arguments to float (#332)
1 parent 66eb746 commit 32e46a4

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

appium/webdriver/extensions/location.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ def set_location(self, latitude, longitude, altitude):
3333
"""
3434
data = {
3535
"location": {
36-
"latitude": str(latitude),
37-
"longitude": str(longitude),
38-
"altitude": str(altitude)
36+
"latitude": float(latitude),
37+
"longitude": float(longitude),
38+
"altitude": float(altitude)
3939
}
4040
}
4141
self.execute(Command.SET_LOCATION, data)

test/unit/webdriver/device/location_test.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
from appium.webdriver.webdriver import WebDriver
2424

25+
FLT_EPSILON = 1e-9
26+
2527

2628
class TestWebDriverLocation(object):
2729

@@ -44,9 +46,9 @@ def test_set_location(self):
4446
assert isinstance(driver.set_location(11.1, 22.2, 33.3), WebDriver) == True
4547

4648
d = get_httpretty_request_body(httpretty.last_request())
47-
assert d['location']['latitude'] == '11.1'
48-
assert d['location']['longitude'] == '22.2'
49-
assert d['location']['altitude'] == '33.3'
49+
assert abs(d['location']['latitude'] - 11.1) <= FLT_EPSILON
50+
assert abs(d['location']['longitude'] - 22.2) <= FLT_EPSILON
51+
assert abs(d['location']['altitude'] - 33.3) <= FLT_EPSILON
5052

5153
@httpretty.activate
5254
def test_location(self):
@@ -57,6 +59,6 @@ def test_location(self):
5759
body='{"value": {"latitude": 11.1, "longitude": 22.2, "altitude": 33.3}}'
5860
)
5961
val = driver.location
60-
assert val['latitude'] == 11.1
61-
assert val['longitude'] == 22.2
62-
assert val['altitude'] == 33.3
62+
assert abs(val['latitude'] - 11.1) <= FLT_EPSILON
63+
assert abs(val['longitude'] - 22.2) <= FLT_EPSILON
64+
assert abs(val['altitude'] - 33.3) <= FLT_EPSILON

0 commit comments

Comments
 (0)