comparison 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
comparison
equal deleted inserted replaced
460:10d4cbffcc07 461:454967511f5c
7 7
8 """Tests for the treepkg.util module""" 8 """Tests for the treepkg.util module"""
9 9
10 import os 10 import os
11 import unittest 11 import unittest
12 import shutil
12 13
13 from filesupport import FileTestMixin 14 from filesupport import FileTestMixin
14 15
15 from treepkg.util import replace_in_file, listdir_abs, md5sum, \ 16 from treepkg.util import replace_in_file, listdir_abs, md5sum, \
16 remove_trailing_slashes, expand_filename 17 remove_trailing_slashes, expand_filename, \
17 18 compress_all_logs
18 19
19 20
20 class TestReplaceInFile(unittest.TestCase, FileTestMixin): 21 class TestReplaceInFile(unittest.TestCase, FileTestMixin):
21 22
22 def runtest(self, orig_contents, expected_contents, pattern, replacement): 23 def runtest(self, orig_contents, expected_contents, pattern, replacement):
100 os.environ['MY_TEST_VAR'] = "def" 101 os.environ['MY_TEST_VAR'] = "def"
101 path = "/abc/${MY_TEST_VAR}/" 102 path = "/abc/${MY_TEST_VAR}/"
102 103
103 self.assertEquals("/abc/def/", expand_filename(path)) 104 self.assertEquals("/abc/def/", expand_filename(path))
104 105
106 class TestCompressAllLogs(unittest.TestCase, FileTestMixin):
107
108 def test_compress_all_logs(self):
109 log_dir = self.create_test_specific_temp_dir()
110 try:
111 for i in range(15):
112 f = open(os.path.join(log_dir, "log_%d.txt" % i), "w")
113 print >> f, "World domination is right at hand!"
114 f.close()
115 ref_log = os.path.join(log_dir, "log_0.txt")
116 compress_all_logs(ref_log)
117 for i in range(15):
118 self.assertTrue(os.path.isfile(os.path.join(
119 log_dir, "log_%d.txt.gz" % i)))
120 finally:
121 shutil.rmtree(log_dir, ignore_errors=True)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)