changeset 479:83fcb1cf6d8f

Avoid 'ValueError: close_fds is not supported on Windows platforms' exception
author Risto Kankkunen <risto.kankkunen@iki.fi>
date Wed, 29 Jul 2009 17:26:29 +0300
parents 37304494cd15
children 7fa100ae1a11
files tests/test_svnwrap.py tests/test_util.py
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test_svnwrap.py
+++ b/tests/test_svnwrap.py
@@ -17,7 +17,8 @@ class TestBasicRepoLayout(unittest.TestC
         inp = open(os.path.join(os.path.dirname(__file__), 'fixtures',
                                 'project_root_at_repo_root.svndump'))
         proc = subprocess.call(['svnadmin', 'load', self.repo_path,],
-                                stdin=inp, close_fds=True,
+                                stdin=inp,
+                                close_fds=test_util.canCloseFds,
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.STDOUT)
         assert proc == 0
@@ -62,7 +63,8 @@ class TestRootAsSubdirOfRepo(TestBasicRe
         inp = open(os.path.join(os.path.dirname(__file__), 'fixtures',
                                 'project_root_not_repo_root.svndump'))
         ret = subprocess.call(['svnadmin', 'load', self.repo_path,],
-                              stdin=inp, close_fds=True,
+                              stdin=inp,
+                              close_fds=test_util.canCloseFds,
                               stdout=subprocess.PIPE,
                               stderr=subprocess.STDOUT)
         assert ret == 0
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -19,6 +19,13 @@ from mercurial import ui
 
 from hgsubversion import util
 
+import sys
+# Documentation for Subprocess.Popen() says:
+#   "Note that on Windows, you cannot set close_fds to true and
+#   also redirect the standard handles by setting stdin, stdout or
+#   stderr."
+canCloseFds='win32' not in sys.platform
+
 # Fixtures that need to be pulled at a subdirectory of the repo path
 subdir = {'truncatedhistory.svndump': '/project2',
           'fetch_missing_files_subdir.svndump': '/foo',