[Python-Dev] test_cwd of test_subprocess.py fails on Win98

Khalid A. B. abkhd at hotmail.com
Wed Oct 13 04:47:59 CEST 2004


Hello.


The test fails because it seems to be comparing "C:\WINDOWS\TEMP" with
"C:\WINDOWS\Temp" and even though they are the same thing in Win98,
they are of cource not equal.

Details follow:


$ python -i
Python 2.4a3 (#56, Oct 13 2004, 02:29:05)
[GCC 3.4.1 (mingw special)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>import os, sys, subprocess
>>>tmpdir = os.getenv("TEMP", "/tmp")
>>>tmpdir = os.path.realpath(tmpdir)
>>>tmpdir
'C:\\WINDOWS\\TEMP'
>>>p = subprocess.Popen([sys.executable, "-c",
...     'import sys,os;' \
...     'sys.stdout.write(os.getcwd())'],
...     stdout=subprocess.PIPE,
...     cwd=tmpdir)
>>>subProcessTmpDir = p.stdout.read()
>>>subProcessTmpDir
'C:\\WINDOWS\\Temp'
>>>tmpdir == subProcessTmpDir
False
>>>



Although I don't know if this will work in other versions of Windows,
here is what fixed it for me:

Index: python/dist/src/Lib/test/test_subprocess.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_subprocess.py,v
retrieving revision 1.4
diff -u -d -r1.4 test_subprocess.py
--- python/dist/src/Lib/test/test_subprocess.py	12 Oct 2004 22:29:54 
-0000	1.4
+++ python/dist/src/Lib/test/test_subprocess.py	13 Oct 2004 02:27:13 -0000
@@ -192,9 +192,16 @@
     def test_cwd(self):
         tmpdir = os.getenv("TEMP", "/tmp")
         tmpdir = os.path.realpath(tmpdir)
-        p = subprocess.Popen([sys.executable, "-c",
-                          'import sys,os;' \
-                          'sys.stdout.write(os.getcwd())'],
+        commandStr = [sys.executable, "-c"]
+        if mswindows:
+            tmpdir = tmpdir.upper()
+            commandStr.append('import sys,os;' \
+                          'sys.stdout.write(os.getcwd().upper())')
+        else:
+            commandStr.append('import sys,os;' \
+                          'sys.stdout.write(os.getcwd())')
+
+        p = subprocess.Popen(commandStr,
                          stdout=subprocess.PIPE,
                          cwd=tmpdir)
         self.assertEqual(p.stdout.read(), tmpdir)

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.com/



More information about the Python-Dev mailing list