SVN: zdaemon/trunk/ No longer uses a hardcoded filename (/tmp/demo.zdsock) in unit tests.

Marius Gedminas <[email protected]>
Newsgroups gmane.comp.web.zope.zope3.cvs
Message-ID <20080904041651.A6E6739646__14390.5515586541$1220501913$gmane$org@cvs.zope.org>
Log message for revision 90780:
  No longer uses a hardcoded filename (/tmp/demo.zdsock) in unit tests.
  This lets you run the tests on Python 2.4 and 2.5 simultaneously without
  spurious errors.
  
  I also thought using a hardcoded filename may be a security issue (clobber any
  file writable by you if anybody else creates a symlink in the publicly-writable
  /tmp), but experiments failed to confirm that.
  
  

Changed:
  U   zdaemon/trunk/CHANGES.txt
  U   zdaemon/trunk/src/zdaemon/README.txt
  U   zdaemon/trunk/src/zdaemon/tests/tests.py

-=-
Modified: zdaemon/trunk/CHANGES.txt
===================================================================
--- zdaemon/trunk/CHANGES.txt	2008-09-04 04:09:00 UTC (rev 90779)
+++ zdaemon/trunk/CHANGES.txt	2008-09-04 04:16:50 UTC (rev 90780)
@@ -9,7 +9,11 @@
 Bugs Fixed
 ----------
 
+- No longer uses a hardcoded filename (/tmp/demo.zdsock) in unit tests.
+  This lets you run the tests on Python 2.4 and 2.5 simultaneously without
+  spurious errors.
 
+
 zdaemon 2.0.2 (2008/04/05)
 ==========================
 

Modified: zdaemon/trunk/src/zdaemon/README.txt
===================================================================
--- zdaemon/trunk/src/zdaemon/README.txt	2008-09-04 04:09:00 UTC (rev 90779)
+++ zdaemon/trunk/src/zdaemon/README.txt	2008-09-04 04:16:50 UTC (rev 90780)
@@ -108,7 +108,7 @@
     ...   program sleep 100
     ...   socket-name /tmp/demo.zdsock
     ... </runner>
-    ... ''')
+    ... '''.replace('/tmp', tmpdir))
 
 
     >>> system("./zdaemon -Cconf start")
@@ -120,7 +120,7 @@
     zdaemon
 
     >>> import os
-    >>> os.path.exists("/tmp/demo.zdsock")
+    >>> os.path.exists("/tmp/demo.zdsock".replace('/tmp', tmpdir))
     True
 
     >>> system("./zdaemon -Cconf stop")
@@ -136,7 +136,7 @@
     ...   program sleep
     ...   socket-name /tmp/demo.zdsock
     ... </runner>
-    ... ''')
+    ... '''.replace('/tmp', tmpdir))
 
     >>> system("./zdaemon -Cconf start 100")
     . .
@@ -166,7 +166,7 @@
     ...   LD_LIBRARY_PATH /home/foo/lib
     ...   HOME /home/foo
     ... </environment>
-    ... ''')
+    ... '''.replace('/tmp', tmpdir))
 
     >>> system("./zdaemon -Cconf fg")
     env

Modified: zdaemon/trunk/src/zdaemon/tests/tests.py
===================================================================
--- zdaemon/trunk/src/zdaemon/tests/tests.py	2008-09-04 04:09:00 UTC (rev 90779)
+++ zdaemon/trunk/src/zdaemon/tests/tests.py	2008-09-04 04:16:50 UTC (rev 90780)
@@ -91,6 +91,9 @@
     test.globs['_td'] = td = []
     here = os.getcwd()
     td.append(lambda : os.chdir(here))
+    tmpdir = tempfile.mkdtemp()
+    td.append(lambda : shutil.rmtree(tmpdir))
+    test.globs['tmpdir'] = tmpdir
     workspace = tempfile.mkdtemp()
     td.append(lambda : shutil.rmtree(workspace))
     os.chdir(workspace)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.