[Checkins] SVN: gocept.selenium/branches/jw-staticfiles-testlayer/src/gocept/selenium/static/ properly cleanout the tempdir/documentroot

Jan-Wijbrand Kolman janwijbrand at gmail.com
Thu Jun 3 09:35:16 EDT 2010


Log message for revision 113004:
  properly cleanout the tempdir/documentroot

Changed:
  U   gocept.selenium/branches/jw-staticfiles-testlayer/src/gocept/selenium/static/__init__.py
  U   gocept.selenium/branches/jw-staticfiles-testlayer/src/gocept/selenium/static/tests/test_static.py

-=-
Modified: gocept.selenium/branches/jw-staticfiles-testlayer/src/gocept/selenium/static/__init__.py
===================================================================
--- gocept.selenium/branches/jw-staticfiles-testlayer/src/gocept/selenium/static/__init__.py	2010-06-03 13:16:05 UTC (rev 113003)
+++ gocept.selenium/branches/jw-staticfiles-testlayer/src/gocept/selenium/static/__init__.py	2010-06-03 13:35:16 UTC (rev 113004)
@@ -59,7 +59,11 @@
         # hook to clear out all the files from the documentroot.
         paths = os.listdir(self.documentroot)
         for path in paths:
-            shutil.rmtree(path)
+            fullpath = os.path.join(self.documentroot, path)
+            if os.path.isdir(fullpath):
+                shutil.rmtree(fullpath)
+                continue
+            os.remove(fullpath)
 
 static_files_layer = StaticFilesLayer()
 

Modified: gocept.selenium/branches/jw-staticfiles-testlayer/src/gocept/selenium/static/tests/test_static.py
===================================================================
--- gocept.selenium/branches/jw-staticfiles-testlayer/src/gocept/selenium/static/tests/test_static.py	2010-06-03 13:16:05 UTC (rev 113003)
+++ gocept.selenium/branches/jw-staticfiles-testlayer/src/gocept/selenium/static/tests/test_static.py	2010-06-03 13:35:16 UTC (rev 113004)
@@ -38,6 +38,7 @@
     def test_documentroot_initially_empty(self):
         documentroot = self.testlayer.documentroot
         self.assert_(not os.listdir(self.testlayer.documentroot))
+
         open(os.path.join(documentroot, 'foo.txt'), 'w').write('Hello World!')
         self.assertEquals(
             ['foo.txt'], os.listdir(self.testlayer.documentroot))
@@ -45,9 +46,11 @@
     def test_documentroot_empty_after_switchdb(self):
         documentroot = self.testlayer.documentroot
         self.assert_(not os.listdir(self.testlayer.documentroot))
+
         open(os.path.join(documentroot, 'bar.txt'), 'w').write('Hello World!')
         self.assertEquals(
             ['bar.txt'], os.listdir(self.testlayer.documentroot))
+
         self.testlayer.switch_db()
         self.assert_(not os.listdir(self.testlayer.documentroot))
 
@@ -63,7 +66,7 @@
 
     def test_documentroot(self):
         default_tmp_dir = tempfile.gettempdir()
-        self.assert_(self.testlayer.documentroot.startswith(default_tmp_dir))
+        self.assert_(self.documentroot.startswith(default_tmp_dir))
 
     def test_using_selenese(self):
         alert_template = pkg_resources.resource_filename(



More information about the checkins mailing list