diff test/test_packager.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 5155b4f9443d
children e83db4482aab
line wrap: on
line diff
--- a/test/test_packager.py	Wed Jun 25 15:15:30 2008 +0000
+++ b/test/test_packager.py	Thu Jun 26 16:23:26 2008 +0000
@@ -101,10 +101,9 @@
 
 
     def setUp(self):
-        self.svndir = self.create_temp_dir(self.id() + "-svn")
-        self.svnworkdir = self.create_temp_dir(self.id() + "-svnwork")
-        self.trackdir = self.create_temp_dir(self.id() + "-track")
-        self.create_files(self.trackdir, self.debian_files)
+        self.svndir = self.create_temp_dir("svn")
+        self.svnworkdir = self.create_temp_dir("svnwork")
+        self.trackdir = self.create_files("track", self.debian_files)
         self.svn_url = create_svn_repository(self.svndir) + "/trunk"
         subversion.checkout(self.svn_url, self.svnworkdir)
         for message, files in self.revisions:
@@ -200,7 +199,7 @@
 class TestPackageGroupStop(unittest.TestCase, FileTestMixin):
 
     def setUp(self):
-        self.trackdir = self.create_temp_dir(self.id() + "-track")
+        self.trackdir = self.create_temp_dir("track")
         self.instructions_file = os.path.join(self.trackdir, "instructions")
 
     def group(self, do_package=True, do_stop=True):
@@ -246,74 +245,74 @@
 
 class TestPackageTrack(unittest.TestCase, FileTestMixin):
 
-    def setUp(self):
-        self.trackdir = self.create_temp_dir(self.id() + "-track")
+    # def setUp(self):
+    #     self.trackdir = self.create_temp_dir("track")
 
     def test_get_revision_numbers(self):
         # Note: The revisions in the pkg dir are not ordered so that we
         # can check whether get_revision_numbers returns a sorted list
         # of revisions
-        self.create_files(self.trackdir,
-                          [("pkg",
-                            [("704195-1",
-                              [("status", ""),
-                               ("src", []),
-                               ("binary", [])]),
-                             ("702432-1",
-                              [("status", ""),
-                               ("src", []),
-                               ("binary", [])])])])
-        track = PackageTrack("testtrack", self.trackdir, "", "", "", "", "")
+        trackdir = self.create_files("track",
+                                     [("pkg",
+                                       [("704195-1",
+                                         [("status", ""),
+                                          ("src", []),
+                                          ("binary", [])]),
+                                        ("702432-1",
+                                         [("status", ""),
+                                          ("src", []),
+                                          ("binary", [])])])])
+        track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
         self.assertEquals(track.get_revision_numbers(), [702432, 704195])
 
     def test_last_packaged_revision_with_no_revisions(self):
-        self.create_files(self.trackdir, [("pkg", [])])
-        track = PackageTrack("testtrack", self.trackdir, "", "", "", "", "")
+        trackdir = self.create_files("track", [("pkg", [])])
+        track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
         self.assertEquals(track.last_packaged_revision(), -1)
 
     def test_last_packaged_revision_several_revisions(self):
-        self.create_files(self.trackdir,
-                          [("pkg",
-                            [("704195-1",
-                              [("status", ""),
-                               ("src", []),
-                               ("binary", [])]),
-                             ("702432-1",
-                              [("status", ""),
-                               ("src", []),
-                               ("binary", [])])])])
-        track = PackageTrack("testtrack", self.trackdir, "", "", "", "", "")
+        trackdir = self.create_files("track",
+                                     [("pkg",
+                                       [("704195-1",
+                                         [("status", ""),
+                                          ("src", []),
+                                          ("binary", [])]),
+                                        ("702432-1",
+                                         [("status", ""),
+                                          ("src", []),
+                                          ("binary", [])])])])
+        track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
         self.assertEquals(track.last_packaged_revision(), 704195)
 
 
 class TestRevisionPackager(unittest.TestCase, FileTestMixin):
 
-    def setUp(self):
-        self.trackdir = self.create_temp_dir(self.id() + "-track")
+    # def setUp(self):
+    #     self.trackdir = self.create_temp_dir("track")
 
     def test_list_source_files(self):
         # Note: The revisions in the pkg dir are not ordered so that we
         # can check whether get_revision_numbers returns a sorted list
         # of revisions
-        self.create_files(self.trackdir,
-                          [("pkg",
-                            [("704195-1",
-                              [("status",
-                                ("TreePackagerStatus 0.0\n"
-                                 "status: binary_package_created\n"
-                                 "start: 2007-09-10 17:16:48\n"
-                                 "stop: 2007-09-11 00:07:36\n")),
-                               ("src", [("test_1.0.orig.tar.gz", ""),
-                                        ("test_1.0-1.diff.gz", ""),
-                                        ("test_1.0-1.dsc", "")]),
-                               ("binary", [])]),
-                             ("702432-1",
-                              [("status", ""),
-                               ("src", []),
-                               ("binary", [])])])])
-        track = PackageTrack("testtrack", self.trackdir, "", "", "", "", "")
+        trackdir = self.create_files("track",
+                                     [("pkg",
+                                       [("704195-1",
+                                         [("status",
+                                           ("TreePackagerStatus 0.0\n"
+                                            "status: binary_package_created\n"
+                                            "start: 2007-09-10 17:16:48\n"
+                                            "stop: 2007-09-11 00:07:36\n")),
+                                          ("src", [("test_1.0.orig.tar.gz", ""),
+                                                   ("test_1.0-1.diff.gz", ""),
+                                                   ("test_1.0-1.dsc", "")]),
+                                          ("binary", [])]),
+                                        ("702432-1",
+                                         [("status", ""),
+                                          ("src", []),
+                                          ("binary", [])])])])
+        track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
         revpkg = RevisionPackager(track, 704195)
-        srcdir = os.path.join(self.trackdir, "pkg", "704195-1", "src")
+        srcdir = os.path.join(trackdir, "pkg", "704195-1", "src")
         self.assertEquals(revpkg.list_source_files(),
                           [os.path.join(srcdir, filename)
                            for filename in ["test_1.0-1.diff.gz",
@@ -324,24 +323,25 @@
         # Note: The revisions in the pkg dir are not ordered so that we
         # can check whether get_revision_numbers returns a sorted list
         # of revisions
-        self.create_files(self.trackdir,
-                          [("pkg",
-                            [("704195-1",
-                              [("status",
-                                ("TreePackagerStatus 0.0\n"
-                                 "status: binary_package_created\n"
-                                 "start: 2007-09-10 17:16:48\n"
-                                 "stop: 2007-09-11 00:07:36\n")),
-                               ("src", []),
-                               ("binary", [("test_1.0-1_i386.deb", ""),
-                                           ("test_1.0-1_i386.changes", "")])]),
-                             ("702432-1",
-                              [("status", ""),
-                               ("src", []),
-                               ("binary", [])])])])
-        track = PackageTrack("testtrack", self.trackdir, "", "", "", "", "")
+        trackdir = self.create_files("track",
+                                     [("pkg",
+                                       [("704195-1",
+                                         [("status",
+                                           ("TreePackagerStatus 0.0\n"
+                                            "status: binary_package_created\n"
+                                            "start: 2007-09-10 17:16:48\n"
+                                            "stop: 2007-09-11 00:07:36\n")),
+                                          ("src", []),
+                                          ("binary",
+                                           [("test_1.0-1_i386.deb", ""),
+                                            ("test_1.0-1_i386.changes", "")])]),
+                                        ("702432-1",
+                                         [("status", ""),
+                                          ("src", []),
+                                          ("binary", [])])])])
+        track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
         revpkg = RevisionPackager(track, 704195)
-        bindir = os.path.join(self.trackdir, "pkg", "704195-1", "binary")
+        bindir = os.path.join(trackdir, "pkg", "704195-1", "binary")
         self.assertEquals(revpkg.list_binary_files(),
                           [os.path.join(bindir, filename)
                            for filename in ["test_1.0-1_i386.changes",
@@ -368,8 +368,7 @@
                                          ""]))])]
 
     def setUp(self):
-        self.directory = self.create_temp_dir(self.id())
-        self.create_files(self.directory, self.files)
+        self.directory = self.create_files("a_module", self.files)
         self.old_path = sys.path
         sys.path = [self.directory] + sys.path
 
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)