changeset 594:069bb2764aaf pytest2

added TestCopy in util/test_filesys.py to test filesys.copytree
author pkumar <contactprashantat@gmail.com>
date Mon, 27 Jun 2011 18:53:21 +0530
parents b3aeaf60adcc
children 1476764d3857
files MoinMoin/util/_tests/test_filesys.py
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/util/_tests/test_filesys.py	Mon Jun 27 00:33:47 2011 +0530
+++ b/MoinMoin/util/_tests/test_filesys.py	Mon Jun 27 18:53:21 2011 +0530
@@ -136,4 +136,29 @@
         assert not os.path.exists(self.src)
 
 
+class TestCopy:
+    """test filesys.copytree"""
+
+    def setup_method(self, method):
+        self.test_dir = tempfile.mkdtemp('', 'copytree1')
+        self.src1 = os.path.join(self.test_dir, "copytree-src1")
+        self.src2 = os.path.join(self.test_dir, "copytree-src2")
+        
+    def teardown_method(self, method):
+        shutil.rmtree(self.test_dir)
+        shutil.rmtree(self.test_dest_dir)
+
+    def makefile(self, src, content):
+        f = open(src, "w")
+        f.write(content)
+        f.close()
+        
+    def test_copytree(self):
+        self.makefile(self.src1, 'src1')
+        self.makefile(self.src2, 'src2')
+        self.test_dest_dir = self.test_dir + '_copy'
+        filesys.copytree(self.test_dir, self.test_dest_dir)
+        # check for the dir contents
+        assert os.listdir(self.test_dir) == os.listdir(self.test_dest_dir)        
+        
 coverage_modules = ['MoinMoin.util.filesys']