Mercurial > treepkg
diff test/test_util.py @ 461:454967511f5c
commit compress all logs patch from Sascha Teichmann
author | Bjoern Ricks <bricks@intevation.de> |
---|---|
date | Mon, 30 Aug 2010 13:32:31 +0000 |
parents | 8e0c81870e5e |
children | ca95be9d033a |
line wrap: on
line diff
--- a/test/test_util.py Fri Aug 27 09:50:04 2010 +0000 +++ b/test/test_util.py Mon Aug 30 13:32:31 2010 +0000 @@ -9,12 +9,13 @@ import os import unittest +import shutil from filesupport import FileTestMixin from treepkg.util import replace_in_file, listdir_abs, md5sum, \ - remove_trailing_slashes, expand_filename - + remove_trailing_slashes, expand_filename, \ + compress_all_logs class TestReplaceInFile(unittest.TestCase, FileTestMixin): @@ -102,3 +103,19 @@ self.assertEquals("/abc/def/", expand_filename(path)) +class TestCompressAllLogs(unittest.TestCase, FileTestMixin): + + def test_compress_all_logs(self): + log_dir = self.create_test_specific_temp_dir() + try: + for i in range(15): + f = open(os.path.join(log_dir, "log_%d.txt" % i), "w") + print >> f, "World domination is right at hand!" + f.close() + ref_log = os.path.join(log_dir, "log_0.txt") + compress_all_logs(ref_log) + for i in range(15): + self.assertTrue(os.path.isfile(os.path.join( + log_dir, "log_%d.txt.gz" % i))) + finally: + shutil.rmtree(log_dir, ignore_errors=True)