Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b1f7f634
Commit
b1f7f634
authored
Mar 06, 2012
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test_pty: fix ResourceWarning warnings
parent
198b291d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
Lib/test/test_pty.py
Lib/test/test_pty.py
+14
-5
No files found.
Lib/test/test_pty.py
View file @
b1f7f634
...
...
@@ -205,6 +205,7 @@ class SmallPtyTests(unittest.TestCase):
self
.
orig_stdout_fileno
=
pty
.
STDOUT_FILENO
self
.
orig_pty_select
=
pty
.
select
self
.
fds
=
[]
# A list of file descriptors to close.
self
.
files
=
[]
self
.
select_rfds_lengths
=
[]
self
.
select_rfds_results
=
[]
...
...
@@ -212,10 +213,15 @@ class SmallPtyTests(unittest.TestCase):
pty
.
STDIN_FILENO
=
self
.
orig_stdin_fileno
pty
.
STDOUT_FILENO
=
self
.
orig_stdout_fileno
pty
.
select
=
self
.
orig_pty_select
for
file
in
self
.
files
:
try
:
file
.
close
()
except
OSError
:
pass
for
fd
in
self
.
fds
:
try
:
os
.
close
(
fd
)
except
:
except
OSError
:
pass
def
_pipe
(
self
):
...
...
@@ -223,6 +229,11 @@ class SmallPtyTests(unittest.TestCase):
self
.
fds
.
extend
(
pipe_fds
)
return
pipe_fds
def
_socketpair
(
self
):
socketpair
=
socket
.
socketpair
()
self
.
files
.
extend
(
socketpair
)
return
socketpair
def
_mock_select
(
self
,
rfds
,
wfds
,
xfds
):
# This will raise IndexError when no more expected calls exist.
self
.
assertEqual
(
self
.
select_rfds_lengths
.
pop
(
0
),
len
(
rfds
))
...
...
@@ -234,9 +245,8 @@ class SmallPtyTests(unittest.TestCase):
pty
.
STDOUT_FILENO
=
mock_stdout_fd
mock_stdin_fd
,
write_to_stdin_fd
=
self
.
_pipe
()
pty
.
STDIN_FILENO
=
mock_stdin_fd
socketpair
=
s
ocket
.
socketpair
()
socketpair
=
s
elf
.
_
socketpair
()
masters
=
[
s
.
fileno
()
for
s
in
socketpair
]
self
.
fds
.
extend
(
masters
)
# Feed data. Smaller than PIPEBUF. These writes will not block.
os
.
write
(
masters
[
1
],
b'from master'
)
...
...
@@ -263,9 +273,8 @@ class SmallPtyTests(unittest.TestCase):
pty
.
STDOUT_FILENO
=
mock_stdout_fd
mock_stdin_fd
,
write_to_stdin_fd
=
self
.
_pipe
()
pty
.
STDIN_FILENO
=
mock_stdin_fd
socketpair
=
s
ocket
.
socketpair
()
socketpair
=
s
elf
.
_
socketpair
()
masters
=
[
s
.
fileno
()
for
s
in
socketpair
]
self
.
fds
.
extend
(
masters
)
os
.
close
(
masters
[
1
])
socketpair
[
1
].
close
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment