Mercurial > treepkg
diff 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 |
line wrap: on
line diff
--- a/test/test_util.py Wed Jun 25 15:15:30 2008 +0000 +++ b/test/test_util.py Thu Jun 26 16:23:26 2008 +0000 @@ -18,7 +18,7 @@ class TestReplaceInFile(unittest.TestCase, FileTestMixin): def runtest(self, orig_contents, expected_contents, pattern, replacement): - filename = self.create_temp_file(self.id(), orig_contents) + filename = self.create_temp_file("orig", orig_contents) changed = replace_in_file(filename, pattern, replacement) self.assertEquals(changed, orig_contents != expected_contents) self.checkFileContents(filename, expected_contents) @@ -54,21 +54,21 @@ class TestListDirAbs(unittest.TestCase, FileTestMixin): def setUp(self): - self.directory = self.create_temp_dir(self.id()) + self.directory = self.create_temp_dir("a_directory") def test_listdir_abs(self): - self.create_files(self.directory, [("foo.orig.tgz", ""), - ("foo.dsc", ""), - ("foo.diff.gz", ""),]) - self.assertEquals(sorted(listdir_abs(self.directory)), - sorted([os.path.join(self.directory, d) + directory = self.create_files("dir", [("foo.orig.tgz", ""), + ("foo.dsc", ""), + ("foo.diff.gz", ""),]) + self.assertEquals(sorted(listdir_abs(directory)), + sorted([os.path.join(directory, d) for d in ["foo.orig.tgz", "foo.dsc", "foo.diff.gz"]])) def test_listdir_abs_pattern(self): - self.create_files(self.directory, [("foo.orig.tgz", ""), - ("foo.dsc", ""), - ("foo.diff.gz", ""),]) - self.assertEquals(sorted(listdir_abs(self.directory, '*.dsc')), - [os.path.join(self.directory, "foo.dsc")]) + directory = self.create_files("dir", [("foo.orig.tgz", ""), + ("foo.dsc", ""), + ("foo.diff.gz", ""),]) + self.assertEquals(sorted(listdir_abs(directory, '*.dsc')), + [os.path.join(directory, "foo.dsc")])