diff options
author | Louis Bouchard <louis.bouchard@canonical.com> | 2015-09-30 16:54:48 +0200 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2015-10-15 12:04:26 +0100 |
commit | 30402b9acd8812176da6d88aed119d8e5bbb9121 (patch) | |
tree | 8e647f4bdb9dfd099d8c222922f11d08b8a709aa /tests/archive_tests.py | |
parent | ca0463f36cd6ab02bd27f5ef9682660a0d212dcd (diff) | |
download | sos-30402b9acd8812176da6d88aed119d8e5bbb9121.tar.gz |
[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 <louis.bouchard@canonical.com>
Diffstat (limited to 'tests/archive_tests.py')
-rw-r--r-- | tests/archive_tests.py | 14 |
1 files changed, 14 insertions, 0 deletions
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): |