summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_support.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-01-19 17:37:42 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-01-19 17:37:42 (GMT)
commit5539c783912d1cc84d9df16322e1083866ad2033 (patch)
tree534c7c8673db7a82b7e0873ef4ae4381d3d2f3d2 /Lib/test/test_support.py
parentc84ebe73a794ae6a50cd380f4f8a71856c095c6e (diff)
downloadcpython-5539c783912d1cc84d9df16322e1083866ad2033.zip
cpython-5539c783912d1cc84d9df16322e1083866ad2033.tar.gz
cpython-5539c783912d1cc84d9df16322e1083866ad2033.tar.bz2
make bad file descriptor tests more robust
Diffstat (limited to 'Lib/test/test_support.py')
-rw-r--r--Lib/test/test_support.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index abaf117..5186a57 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -357,6 +357,18 @@ def sortdict(dict):
withcommas = ", ".join(reprpairs)
return "{%s}" % withcommas
+def make_bad_fd():
+ """
+ Create an invalid file descriptor by opening and closing a file and return
+ its fd.
+ """
+ file = open(TESTFN, "wb")
+ try:
+ return file.fileno()
+ finally:
+ file.close()
+ unlink(TESTFN)
+
def check_syntax_error(testcase, statement):
try:
compile(statement, '<test string>', 'exec')