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