From c9280c70c096f311ef8c87150a1808f00a319571 Mon Sep 17 00:00:00 2001 From: Christopher Fricke Date: Fri, 26 Jul 2019 15:21:25 -0400 Subject: [PATCH] Fix __repr__ function of SmartDevice (#178) --- pyHS100/smartdevice.py | 2 +- pyHS100/tests/test_fixtures.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pyHS100/smartdevice.py b/pyHS100/smartdevice.py index 5292a778..f37c4818 100755 --- a/pyHS100/smartdevice.py +++ b/pyHS100/smartdevice.py @@ -616,7 +616,7 @@ class SmartDevice: is_on = self.is_on if callable(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.model, self.host, diff --git a/pyHS100/tests/test_fixtures.py b/pyHS100/tests/test_fixtures.py index 2dfa9216..e33cb24d 100644 --- a/pyHS100/tests/test_fixtures.py +++ b/pyHS100/tests/test_fixtures.py @@ -654,3 +654,10 @@ def test_cache_invalidates(dev): dev.get_sysinfo() assert query_mock.call_count == 2 # 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)) +