summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-11-09 19:34:43 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-11-09 19:34:43 (GMT)
commit734c7fb13165e9c299c2522f06da5b31a50af941 (patch)
tree1cb4847ec3cdeb92303483aa11bca65398bb5840
parenta4e5c71962a093dadf425b7a7b9d83fe4063f883 (diff)
downloadcpython-734c7fb13165e9c299c2522f06da5b31a50af941.zip
cpython-734c7fb13165e9c299c2522f06da5b31a50af941.tar.gz
cpython-734c7fb13165e9c299c2522f06da5b31a50af941.tar.bz2
Fiddle with new test cases -- verify that we get a sensible error
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.
-rw-r--r--Lib/test/test_file.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py
index cb1bdce..931e33d 100644
--- a/Lib/test/test_file.py
+++ b/Lib/test/test_file.py
@@ -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