|
1 | 1 | import time |
| 2 | +import pytest |
2 | 3 | import unittest |
3 | 4 | import unittest.mock as mock |
4 | 5 | import bluepy |
@@ -142,18 +143,22 @@ def e(): |
142 | 143 | e() |
143 | 144 |
|
144 | 145 |
|
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