]> granicus.if.org Git - python/commitdiff
Fiddle with new test cases -- verify that we get a sensible error
authorJeremy Hylton <jeremy@alum.mit.edu>
Fri, 9 Nov 2001 19:34:43 +0000 (19:34 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Fri, 9 Nov 2001 19:34:43 +0000 (19:34 +0000)
message for bad mode argument -- so that it doesn't fail on Windows.

It's hack.  We know that errno is set to 0 in this case on Windows, so
check for that specifically.

Lib/test/test_file.py

index cb1bdce08e0d8b35d210b5a6cab3ac97d5a0760e..931e33db36ea114648a42d949bdf8c30d349356a 100644 (file)
@@ -46,14 +46,17 @@ else:
     print "writelines accepted sequence of non-string objects"
 f.close()
 
-# verify that we get a sensible error message for bad made argument
+# verify that we get a sensible error message for bad mode argument
 bad_mode = "qwerty"
 try:
     open(TESTFN, bad_mode)
 except IOError, msg:
-    s = str(msg)
-    if s.find(TESTFN) != -1 or s.find(bad_mode) == -1:
-        print "bad error message for invalid mode: %s" % s
+    if msg[0] != 0:
+        s = str(msg)
+        if s.find(TESTFN) != -1 or s.find(bad_mode) == -1:
+            print "bad error message for invalid mode: %s" % s
+    # if msg[0] == 0, we're probably on Windows where there may be
+    # no obvious way to discover why open() failed.
 else:
     print "no error for invalid mode: %s" % bad_mode