Skip to content

Commit 7b730bf

Browse files
committed
Fix logging in a test
1 parent 547556a commit 7b730bf

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tests/test_jobs.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Test the GetFileJob."""
22

33
import asyncio
4+
import logging
45
import os
56
from binascii import hexlify
67
from hashlib import sha256
@@ -129,7 +130,6 @@ def test_run(self):
129130

130131

131132
class TestFirmwareUpdateJob(TestCase):
132-
133133
def test_update_sha(self):
134134
"""Should update the SHA256 hash with each update"""
135135
job = FirmwareUpdateJob("ota", ["firmware.bin"])
@@ -209,6 +209,15 @@ def test_output(self):
209209

210210

211211
class TestRebootJob(TestCase):
212+
def setUp(self):
213+
# Turn off logging during tests
214+
self.logger = logging.getLogger()
215+
self.old_level = self.logger.level
216+
self.logger.setLevel(logging.CRITICAL)
217+
218+
def tearDown(self):
219+
self.logger.setLevel(self.old_level)
220+
212221
def test_run_hard(self):
213222
"""Reboot job should signal and perform a hard reboot"""
214223
job = RebootJob("reboot", ["hard"])
@@ -219,6 +228,5 @@ def test_run_hard(self):
219228
def test_run_soft(self):
220229
"""Reboot job should signal a soft reboot"""
221230
job = RebootJob("reboot", ["soft"])
222-
# TODO: turn off or mock logger here to ignore the output
223231
output = job.output().read().decode("utf-8").strip()
224232
self.assertEqual(output, "Performing soft reboot")

0 commit comments

Comments
 (0)