From 8499a404322dc37af2afae05ec5630b366656b27 Mon Sep 17 00:00:00 2001 From: Alex Schofield Date: Fri, 7 Feb 2025 15:13:21 +0000 Subject: improve debug flag checks for pytest --- tests/test_discover.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/test_discover.py b/tests/test_discover.py index 22e1d73..c6d6ab2 100644 --- a/tests/test_discover.py +++ b/tests/test_discover.py @@ -1,6 +1,6 @@ from unittest import IsolatedAsyncioTestCase from unittest.mock import AsyncMock, patch -from discover import discover +from discover import main from bleak.backends.device import BLEDevice import os @@ -8,11 +8,10 @@ class TestDiscover(IsolatedAsyncioTestCase): @patch('src.discover.BleakScanner.discover', new_callable=AsyncMock) async def test_device_discovery_successful(self, mock_discover): device_1 = BLEDevice(address="AA:BB:CC:DD:EE:FF", name="TP350S", details={}, rssi=-40) - device_2 = BLEDevice(address="GG:HH:II:JJ:KK:LL", name="Device 2", details={}, rssi=-64) mock_discover.return_value = [device_1] - result = await discover() + result = await main(debug_flag=False) expected = [ {"name": "TP350S", "address": "AA:BB:CC:DD:EE:FF"}, @@ -27,8 +26,7 @@ class TestDiscover(IsolatedAsyncioTestCase): mock_discover.return_value = [device_1, device_2] - with patch.dict(os.environ, {"DEBUG": "TRUE"}): - result = await discover() + result = await main(debug_flag=True) expected = [ {"name": "TP350S", "address": "AA:BB:CC:DD:EE:FF"}, -- cgit v1.2.3