diff options
author | Pavel Moravec <pmoravec@redhat.com> | 2016-01-13 13:59:52 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2016-06-27 16:51:18 +0100 |
commit | 1fd12690870e85e8ac83b0e99bb272ce4489dc60 (patch) | |
tree | cfd928e419b87e9cc89cbb4185070db44408191c /tests | |
parent | b523592d69b4eebd23a83a06ff3df7d906ddd95f (diff) | |
download | sos-1fd12690870e85e8ac83b0e99bb272ce4489dc60.tar.gz |
[reporting] deal with UTF-8 characters
replace str class functions by unicode variants:
1) "\n".join(buf) needs to pass decoded UTF-8 text
2) uniform python2 and python3 str/unicode type
3) fd.write needs to replace str(..) by some other function name
4) fd.write needs to encode UTF-8
5) update tests/report_tests.py like 2)
Resolves: #722, #723.
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/report_tests.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/report_tests.py b/tests/report_tests.py index 39635104..dd390669 100644 --- a/tests/report_tests.py +++ b/tests/report_tests.py @@ -66,19 +66,19 @@ class TestPlainReport(unittest.TestCase): self.div = PlainTextReport.DIVIDER def test_basic(self): - self.assertEquals("", str(PlainTextReport(self.report))) + self.assertEquals("", PlainTextReport(self.report).unicode()) def test_one_section(self): self.report.add(self.section) - self.assertEquals("plugin\n" + self.div, str(PlainTextReport(self.report))) + self.assertEquals("plugin\n" + self.div, PlainTextReport(self.report).unicode()) def test_two_sections(self): section1 = Section(name="first") section2 = Section(name="second") self.report.add(section1, section2) - self.assertEquals("first\n" + self.div + "\nsecond\n" + self.div, str(PlainTextReport(self.report))) + self.assertEquals("first\n" + self.div + "\nsecond\n" + self.div, PlainTextReport(self.report).unicode()) def test_command(self): cmd = Command(name="ls -al /foo/bar/baz", @@ -88,7 +88,7 @@ class TestPlainReport(unittest.TestCase): self.report.add(self.section) self.assertEquals("plugin\n" + self.div + "\n- commands executed:\n * ls -al /foo/bar/baz", - str(PlainTextReport(self.report))) + PlainTextReport(self.report).unicode()) def test_copied_file(self): cf = CopiedFile(name="/etc/hosts", href="etc/hosts") @@ -96,7 +96,7 @@ class TestPlainReport(unittest.TestCase): self.report.add(self.section) self.assertEquals("plugin\n" + self.div + "\n- files copied:\n * /etc/hosts", - str(PlainTextReport(self.report))) + PlainTextReport(self.report).unicode()) def test_created_file(self): crf = CreatedFile(name="sample.txt") @@ -104,7 +104,7 @@ class TestPlainReport(unittest.TestCase): self.report.add(self.section) self.assertEquals("plugin\n" + self.div + "\n- files created:\n * sample.txt", - str(PlainTextReport(self.report))) + PlainTextReport(self.report).unicode()) def test_alert(self): alrt = Alert("this is an alert") @@ -112,7 +112,7 @@ class TestPlainReport(unittest.TestCase): self.report.add(self.section) self.assertEquals("plugin\n" + self.div + "\n- alerts:\n ! this is an alert", - str(PlainTextReport(self.report))) + PlainTextReport(self.report).unicode()) if __name__ == "__main__": unittest.main() |