Skip to content

Commit 419228e

Browse files
author
benjamin.peterson
committed
check the errno in bad fd cases
git-svn-id: http://svn.python.org/projects/python/trunk@69129 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 4b54e5e commit 419228e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Lib/test/test_os.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# portable than they had been thought to be.
44

55
import os
6+
import errno
67
import unittest
78
import warnings
89
import sys
@@ -249,7 +250,6 @@ def test_statvfs_attributes(self):
249250
result = os.statvfs(self.fname)
250251
except OSError, e:
251252
# On AtheOS, glibc always returns ENOSYS
252-
import errno
253253
if e.errno == errno.ENOSYS:
254254
return
255255

@@ -549,7 +549,13 @@ def helper(self):
549549
locals()["test_"+f] = get_single(f)
550550

551551
def check(self, f, *args):
552-
self.assertRaises(OSError, f, test_support.make_bad_fd(), *args)
552+
try:
553+
f(test_support.make_bad_fd(), *args)
554+
except OSError as e:
555+
self.assertEqual(e.errno, errno.EBADF)
556+
else:
557+
self.fail("%r didn't raise a OSError with a bad file descriptor"
558+
% f)
553559

554560
def test_isatty(self):
555561
if hasattr(os, "isatty"):

0 commit comments

Comments
 (0)