[py-svn] r17354 - py/dist/py/misc

arigo at codespeak.net arigo at codespeak.net
Thu Sep 8 12:03:55 CEST 2005


Author: arigo
Date: Thu Sep  8 12:03:54 2005
New Revision: 17354

Modified:
   py/dist/py/misc/rest.py
Log:
Grumble, distutils depends on the current directory in some quite implicit
places (e.g. there is an os.getcwd() in the logic that looks for the
stylesheet).

Bug found while running py.test in svn/pypy/dist/pypy: the test "doc/news.txt"
fails, although it works if run from within the doc directory.



Modified: py/dist/py/misc/rest.py
==============================================================================
--- py/dist/py/misc/rest.py	(original)
+++ py/dist/py/misc/rest.py	Thu Sep  8 12:03:54 2005
@@ -23,8 +23,15 @@
         #'halt' : 0, # 'info',
         'halt_level' : 2, 
     }
-    return publish_string(source, str(source_path), writer_name='html',
-                          settings_overrides=kwargs)
+    # docutils uses os.getcwd() :-(
+    source_path = os.path.abspath(str(source_path))
+    prevdir = os.getcwd()
+    try:
+        os.chdir(os.path.dirname(source_path))
+        return publish_string(source, source_path, writer_name='html',
+                              settings_overrides=kwargs)
+    finally:
+        os.chdir(prevdir)
 
 def process(txtpath, encoding='latin1'):
     """ process a textfile """



More information about the pytest-commit mailing list