From 30402b9acd8812176da6d88aed119d8e5bbb9121 Mon Sep 17 00:00:00 2001 From: Louis Bouchard Date: Wed, 30 Sep 2015 16:54:48 +0200 Subject: [archive] Add test to highlight py3 specific error When add_string receives output from tail() it fails in py3 since tail() returns a byte object. Mimic this behavior. Signed-off-by: Louis Bouchard --- tests/archive_tests.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/archive_tests.py b/tests/archive_tests.py index 70979093..dac02a04 100644 --- a/tests/archive_tests.py +++ b/tests/archive_tests.py @@ -8,6 +8,7 @@ import tempfile import shutil from sos.archive import TarFileArchive +from sos.utilities import tail # PYCOMPAT import six @@ -38,6 +39,19 @@ class TarFileArchiveTest(unittest.TestCase): self.check_for_file('test/tests/ziptest') + # when the string comes from tail() output + def test_add_string_from_file(self): + self.copy_strings = [] + testfile = tempfile.NamedTemporaryFile(dir=self.tmpdir, delete=False) + testfile.write(six.b("*" * 1000)) + testfile.flush() + testfile.close() + + self.copy_strings.append((tail(testfile.name, 100), 'string_test.txt')) + self.tf.add_string(self.copy_strings[0][0], 'tests/string_test.txt') + self.tf.finalize('auto') + + # Since commit 179d9bb add_file does not support recursive directory # addition. Disable this test for now. # def test_add_dir(self): -- cgit