[Zope-CVS] CVS: Packages/zpkgtools/zpkgtools/tests - test_cvsloader.py:1.2

Fred L. Drake, Jr. fred at zope.com
Mon Mar 8 14:22:14 EST 2004


Update of /cvs-repository/Packages/zpkgtools/zpkgtools/tests
In directory cvs.zope.org:/tmp/cvs-serv25409

Modified Files:
	test_cvsloader.py 
Log Message:
refactor tests that use a CVS working directory so the
creation/cleanup of the synthetic working directory is handled by a
base class that can be re-used


=== Packages/zpkgtools/zpkgtools/tests/test_cvsloader.py 1.1 => 1.2 ===
--- Packages/zpkgtools/zpkgtools/tests/test_cvsloader.py:1.1	Fri Mar  5 16:39:22 2004
+++ Packages/zpkgtools/zpkgtools/tests/test_cvsloader.py	Mon Mar  8 14:22:13 2004
@@ -213,29 +213,15 @@
                           cvsloader.parse, "http://www.example.org/")
 
 
-class CvsWorkingDirectoryTestCase(unittest.TestCase):
+class CvsWorkingDirectoryBase(unittest.TestCase):
 
     def setUp(self):
-        self.destination = tempfile.mkdtemp(prefix="test_cvsloader_")
-        self.cvsdir = os.path.join(self.destination, "CVS")
+        self.workingdir = tempfile.mkdtemp(prefix="test-workdir-")
+        self.cvsdir = os.path.join(self.workingdir, "CVS")
         os.mkdir(self.cvsdir)
-        self.filename = os.path.join(self.destination, "file.txt")
-        f = open(self.filename, "w")
-        f.close()
 
     def tearDown(self):
-        shutil.rmtree(self.destination)
-
-    def check(self, filename,
-              type, username, password, host, cvsroot, path, tag):
-        cvsurl = cvsloader.fromPath(filename)
-        self.assertEqual(cvsurl.type, type)
-        self.assertEqual(cvsurl.username, username)
-        self.assertEqual(cvsurl.password, password)
-        self.assertEqual(cvsurl.host, host)
-        self.assertEqual(cvsurl.cvsroot, cvsroot)
-        self.assertEqual(cvsurl.path, path)
-        self.assertEqual(cvsurl.tag, tag)
+        shutil.rmtree(self.workingdir)
 
     def initialize(self, root, repository, tag=None):
         self.writeCvsFile("Root", root + "\n")
@@ -248,13 +234,33 @@
         f.write(content)
         f.close()
 
+
+class CvsWorkingDirectoryTestCase(CvsWorkingDirectoryBase):
+
+    def setUp(self):
+        super(CvsWorkingDirectoryTestCase, self).setUp()
+        self.filename = os.path.join(self.workingdir, "file.txt")
+        f = open(self.filename, "w")
+        f.close()
+
+    def check(self, filename,
+              type, username, password, host, cvsroot, path, tag):
+        cvsurl = cvsloader.fromPath(filename)
+        self.assertEqual(cvsurl.type, type)
+        self.assertEqual(cvsurl.username, username)
+        self.assertEqual(cvsurl.password, password)
+        self.assertEqual(cvsurl.host, host)
+        self.assertEqual(cvsurl.cvsroot, cvsroot)
+        self.assertEqual(cvsurl.path, path)
+        self.assertEqual(cvsurl.tag, tag)
+
     # tests
 
     def test_without_tag(self):
         self.initialize(":ext:cvs.example.org:/cvsroot",
                         "module/package")
         # Check the directory itself:
-        self.check(self.destination,
+        self.check(self.workingdir,
                    "ext", None, None, "cvs.example.org", "/cvsroot",
                    "module/package/", None)
         # And for a contained file:
@@ -267,7 +273,7 @@
                         "module/package",
                         "TAG")
         # Check the directory itself:
-        self.check(self.destination,
+        self.check(self.workingdir,
                    "ext", None, None, "cvs.example.org", "/cvsroot",
                    "module/package/", "TAG")
         # And for a contained file:
@@ -278,7 +284,7 @@
     def test_without_username(self):
         self.initialize(":ext:myuser at cvs.example.org:/cvsroot",
                         "module/package")
-        self.check(self.destination,
+        self.check(self.workingdir,
                    "ext", "myuser", None, "cvs.example.org", "/cvsroot",
                    "module/package/", None)
 




More information about the Zope-CVS mailing list