Skip to content

Commit 704a80b

Browse files
committed
Uncover test fall-throughs
1 parent 6b9b7e4 commit 704a80b

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

tests/test_smile.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ async def connect_wrapper(self, raise_timeout=False, fail_auth=False):
275275
try:
276276
_LOGGER.warning("Connecting to device with invalid credentials:")
277277
await self.connect(fail_auth=fail_auth)
278-
_LOGGER.error(" - invalid credentials not handled")
279-
raise self.ConnectError
278+
_LOGGER.error(" - invalid credentials not handled") # pragma: no cover
279+
raise self.ConnectError # pragma: no cover
280280
except pw_exceptions.InvalidAuthentication:
281281
_LOGGER.info(" + successfully aborted on credentials missing.")
282282
raise pw_exceptions.InvalidAuthentication
@@ -288,16 +288,16 @@ async def connect_wrapper(self, raise_timeout=False, fail_auth=False):
288288
try:
289289
_LOGGER.warning("Connecting to device exceeding timeout in response:")
290290
await self.connect(timeout=True)
291-
_LOGGER.error(" - timeout not handled")
292-
raise self.ConnectError
291+
_LOGGER.error(" - timeout not handled") # pragma: no cover
292+
raise self.ConnectError # pragma: no cover
293293
except (pw_exceptions.DeviceTimeoutError, pw_exceptions.ResponseError):
294294
_LOGGER.info(" + successfully passed timeout handling.")
295295

296296
try:
297297
_LOGGER.warning("Connecting to device with missing data:")
298298
await self.connect(broken=True)
299-
_LOGGER.error(" - broken information not handled")
300-
raise self.ConnectError
299+
_LOGGER.error(" - broken information not handled") # pragma: no cover
300+
raise self.ConnectError # pragma: no cover
301301
except pw_exceptions.InvalidXMLError:
302302
_LOGGER.info(" + successfully passed XML issue handling.")
303303

@@ -405,14 +405,14 @@ async def tinker_switch(
405405
):
406406
if unhappy:
407407
_LOGGER.info(" + failed as expected")
408-
else:
408+
else: # pragma: no cover
409409
_LOGGER.info(" - failed unexpectedly")
410410
raise self.UnexpectedError
411411

412412
@pytest.mark.asyncio
413413
async def tinker_thermostat(self, smile, loc_id, good_schemas=None, unhappy=False):
414414
"""Toggle various climate settings to test functionality."""
415-
if good_schemas is None:
415+
if good_schemas is None: # pragma: no cover
416416
good_schemas = ["Weekschema"]
417417

418418
_LOGGER.info("Asserting modifying settings in location (%s):", loc_id)
@@ -428,7 +428,7 @@ async def tinker_thermostat(self, smile, loc_id, good_schemas=None, unhappy=Fals
428428
):
429429
if unhappy:
430430
_LOGGER.info(" + failed as expected")
431-
else:
431+
else: # pragma: no cover
432432
_LOGGER.info(" - failed unexpectedly")
433433
raise self.UnexpectedError
434434

@@ -450,7 +450,7 @@ async def tinker_thermostat(self, smile, loc_id, good_schemas=None, unhappy=Fals
450450
):
451451
if unhappy:
452452
_LOGGER.info(" + failed as expected")
453-
else:
453+
else: # pragma: no cover
454454
_LOGGER.info(" - failed unexpectedly")
455455
raise self.UnexpectedError
456456

@@ -476,10 +476,10 @@ async def tinker_thermostat(self, smile, loc_id, good_schemas=None, unhappy=Fals
476476
):
477477
if unhappy:
478478
_LOGGER.info(" + failed as expected before intended failure")
479-
else:
479+
else: # pragma: no cover
480480
_LOGGER.info(" - succeeded unexpectedly for some reason")
481481
raise self.UnexpectedError
482-
else:
482+
else: # pragma: no cover
483483
_LOGGER.info("- Skipping schema adjustments")
484484

485485
@pytest.mark.asyncio
@@ -1474,7 +1474,7 @@ async def test_fail_legacy_system(self):
14741474
self.smile_setup = "faulty_stretch"
14751475
try:
14761476
_server, _smile, _client = await self.connect_wrapper()
1477-
assert False
1477+
assert False # pragma: no cover
14781478
except pw_exceptions.ConnectionFailedError:
14791479
assert True
14801480

@@ -1485,7 +1485,7 @@ async def test_invalid_credentials(self):
14851485
self.smile_setup = "p1v4"
14861486
try:
14871487
await self.connect_wrapper(fail_auth=True)
1488-
assert False
1488+
assert False # pragma: no cover
14891489
except pw_exceptions.InvalidAuthentication:
14901490
_LOGGER.debug("InvalidAuthentication raised successfully")
14911491
assert True
@@ -1497,6 +1497,7 @@ async def test_connect_fail_firmware(self):
14971497
self.smile_setup = "fail_firmware"
14981498
try:
14991499
await self.connect_wrapper()
1500+
assert False # pragma: no cover
15001501
except pw_exceptions.UnsupportedDeviceError:
15011502
assert True
15021503

0 commit comments

Comments
 (0)