I have a BLE device. I want to connect to it, run all my tests then deconnect. Here is what versions I'm using: bleak: "0.22.2"; bleak-winrt: "1.2.0"; python_full_version: "3.11.9"
class MyTest(unittest.IsolatedAsyncioTestCase):
async def asyncSetUp(self):
await super().asyncSetUp()
self.device = Device()
self.assertTrue(await self.device.connect())
async def asyncTearDown(self):
await super().asyncTearDown()
await self.device.disconnect()
async def test_a(self):
async def test_b(self):
async def test_c(self):
I want to use the benefit of the bluetooth low energy and not pair with the device.
Here is my problem, asyncSetUp and asyncTearDown are methods that are called before and after each test. So the sequence right now is: connect, run test_a, deconnect; connect, test_b, deconnect...
Which is really inefficient.
I would like something like that: connect, run test_a test_b...; deconnect.
I need something like setUpClass/tearDownClass (or even better something like setUpModule), but the problem is that they are not async, however, device.connect is async and needs to be awaited.
Is there a known solution for this problem?