Fix __repr__ function of SmartDevice (#178)

This commit is contained in:
Christopher Fricke 2019-07-26 15:21:25 -04:00 committed by Teemu R
parent 2c79febae4
commit c9280c70c0
2 changed files with 8 additions and 1 deletions

View File

@ -616,7 +616,7 @@ class SmartDevice:
is_on = self.is_on is_on = self.is_on
if callable(is_on): if callable(is_on):
is_on = is_on() is_on = is_on()
return "<%s at %s (%s), is_on: %s - dev specific: %s>" % ( return "<%s model %s at %s (%s), is_on: %s - dev specific: %s>" % (
self.__class__.__name__, self.__class__.__name__,
self.model, self.model,
self.host, self.host,

View File

@ -654,3 +654,10 @@ def test_cache_invalidates(dev):
dev.get_sysinfo() dev.get_sysinfo()
assert query_mock.call_count == 2 assert query_mock.call_count == 2
# assert query_mock.called_once() # assert query_mock.called_once()
def test_representation(dev):
import re
pattern = re.compile("<.* model .* at .* (.*), is_on: .* - dev specific: .*>")
assert pattern.match(str(dev))