comparison test/test_util.py @ 185:e1c7cd896310

Rework test/filesupport.py so that test cases always use their own temporary directory. Before, the test cases had to ensure this themselves. Adapt the test cases.
author Bernhard Herzog <bh@intevation.de>
date Thu, 26 Jun 2008 16:23:26 +0000
parents 261b75d7b972
children e3ab8aca2b08
comparison
equal deleted inserted replaced
184:83c77307ffb1 185:e1c7cd896310
16 16
17 17
18 class TestReplaceInFile(unittest.TestCase, FileTestMixin): 18 class TestReplaceInFile(unittest.TestCase, FileTestMixin):
19 19
20 def runtest(self, orig_contents, expected_contents, pattern, replacement): 20 def runtest(self, orig_contents, expected_contents, pattern, replacement):
21 filename = self.create_temp_file(self.id(), orig_contents) 21 filename = self.create_temp_file("orig", orig_contents)
22 changed = replace_in_file(filename, pattern, replacement) 22 changed = replace_in_file(filename, pattern, replacement)
23 self.assertEquals(changed, orig_contents != expected_contents) 23 self.assertEquals(changed, orig_contents != expected_contents)
24 self.checkFileContents(filename, expected_contents) 24 self.checkFileContents(filename, expected_contents)
25 25
26 def test_version_replacement(self): 26 def test_version_replacement(self):
52 52
53 53
54 class TestListDirAbs(unittest.TestCase, FileTestMixin): 54 class TestListDirAbs(unittest.TestCase, FileTestMixin):
55 55
56 def setUp(self): 56 def setUp(self):
57 self.directory = self.create_temp_dir(self.id()) 57 self.directory = self.create_temp_dir("a_directory")
58 58
59 def test_listdir_abs(self): 59 def test_listdir_abs(self):
60 self.create_files(self.directory, [("foo.orig.tgz", ""), 60 directory = self.create_files("dir", [("foo.orig.tgz", ""),
61 ("foo.dsc", ""), 61 ("foo.dsc", ""),
62 ("foo.diff.gz", ""),]) 62 ("foo.diff.gz", ""),])
63 self.assertEquals(sorted(listdir_abs(self.directory)), 63 self.assertEquals(sorted(listdir_abs(directory)),
64 sorted([os.path.join(self.directory, d) 64 sorted([os.path.join(directory, d)
65 for d in ["foo.orig.tgz", "foo.dsc", 65 for d in ["foo.orig.tgz", "foo.dsc",
66 "foo.diff.gz"]])) 66 "foo.diff.gz"]]))
67 67
68 def test_listdir_abs_pattern(self): 68 def test_listdir_abs_pattern(self):
69 self.create_files(self.directory, [("foo.orig.tgz", ""), 69 directory = self.create_files("dir", [("foo.orig.tgz", ""),
70 ("foo.dsc", ""), 70 ("foo.dsc", ""),
71 ("foo.diff.gz", ""),]) 71 ("foo.diff.gz", ""),])
72 self.assertEquals(sorted(listdir_abs(self.directory, '*.dsc')), 72 self.assertEquals(sorted(listdir_abs(directory, '*.dsc')),
73 [os.path.join(self.directory, "foo.dsc")]) 73 [os.path.join(directory, "foo.dsc")])
74 74
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)