mirror of
https://github.com/python/cpython.git
synced 2025-11-20 02:50:14 +00:00
make bad file descriptor tests more robust
This commit is contained in:
parent
c84ebe73a7
commit
5539c78391
3 changed files with 32 additions and 15 deletions
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue