-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
checkbox-support/checkbox_support/scripts/tests/test_fwts_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# | ||
# This file is part of Checkbox. | ||
# | ||
# Copyright 2013 Canonical Ltd. | ||
# | ||
# Checkbox is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 3, | ||
# as published by the Free Software Foundation. | ||
|
||
# | ||
# Checkbox is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import unittest | ||
|
||
from tempfile import NamedTemporaryFile | ||
import os | ||
from io import StringIO | ||
|
||
from checkbox_support.scripts.fwts_test import print_log | ||
from unittest.mock import patch | ||
|
||
|
||
class LogPrinterTest(unittest.TestCase): | ||
def setUp(self): | ||
self.logfile = NamedTemporaryFile(delete=False) | ||
|
||
@patch("sys.stdout", new_callable=StringIO) | ||
def test_logfile_with_encoding_error(self, mock_stdout): | ||
with open(self.logfile.name, "wb") as f: | ||
f.write(b"Cannot read PCI config for device 0000:00:\xa1") | ||
f.write(b"<85>)PNP0B00:00\n") | ||
f.write(b"SKIPPED: Test 2, Could not guess cache type.\n") | ||
print_log(self.logfile.name) | ||
self.assertEqual( | ||
mock_stdout.getvalue(), | ||
"WARNING: Found bad char in " + self.logfile.name, | ||
) | ||
os.unlink(self.logfile.name) | ||
|
||
def tearDown(self): | ||
try: | ||
os.unlink(self.logfile.name) | ||
except OSError: | ||
pass |