Fix test failed in py35 (#23002)

pull/23019/head
Jason Hu 2019-04-11 12:52:02 -07:00 committed by GitHub
parent 02347df140
commit ac7f1a7a37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 12 deletions

View File

@ -45,18 +45,22 @@ class TestDemoPlatform(unittest.TestCase):
all_states = self.hass.states.all()
assert len(all_states) == NUMBER_OF_DEMO_DEVICES + 1
# Check a single device's attributes.
state_first_entry = all_states[1] # 0 is zone
assert abs(
state_first_entry.attributes['latitude'] -
self.hass.config.latitude
) < 1.0
assert abs(
state_first_entry.attributes['longitude'] -
self.hass.config.longitude
) < 1.0
assert state_first_entry.attributes['unit_of_measurement'] == \
DEFAULT_UNIT_OF_MEASUREMENT
for state in all_states:
# Check a single device's attributes.
if state.domain != geo_location.DOMAIN:
# ignore home zone state
continue
assert abs(
state.attributes['latitude'] -
self.hass.config.latitude
) < 1.0
assert abs(
state.attributes['longitude'] -
self.hass.config.longitude
) < 1.0
assert state.attributes['unit_of_measurement'] == \
DEFAULT_UNIT_OF_MEASUREMENT
# Update (replaces 1 device).
fire_time_changed(self.hass, utcnow + DEFAULT_UPDATE_INTERVAL)
self.hass.block_till_done()