Skip to content

Commit afbcccc

Browse files
committed
test: refactore tests
1 parent 3ce32f3 commit afbcccc

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

tests/unit/test_tion.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import time
2+
import pytest
23
import unittest
34
import unittest.mock as mock
45
import bluepy
@@ -142,18 +143,22 @@ def e():
142143
e()
143144

144145

145-
class TionTests(unittest.TestCase):
146-
def setUp(self):
147-
self.instances = [tion, LiteFamily, Lite, S3, S4]
148-
149-
def test_DecodeTemperature(self):
150-
self.assertEqual(tion.decode_temperature(0x09), 9, "Should be 9")
151-
self.assertEqual(tion.decode_temperature(0xFF), -1, "Should be -1")
152-
153-
def test_mac(self):
154-
"""mac property should be same as in init"""
155-
target = 'foo'
156-
for s in self.instances:
157-
with self.subTest(test_instance=s):
158-
t_tion = s(target)
159-
self.assertEqual(t_tion.mac, target)
146+
@pytest.mark.parametrize(
147+
"raw_temperature, result",
148+
[
149+
[0x09, 9],
150+
[0xFF, -1]
151+
]
152+
)
153+
def test_decode_temperature(raw_temperature, result):
154+
assert tion.decode_temperature(raw_temperature) == result
155+
156+
157+
@pytest.mark.parametrize(
158+
"instance",
159+
[tion, LiteFamily, Lite, S3, S4]
160+
)
161+
def test_mac(instance):
162+
target = 'foo'
163+
t_tion = instance(target)
164+
assert t_tion.mac == target

0 commit comments

Comments
 (0)