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
7ba6b0f9
Commit
7ba6b0f9
authored
Sep 08, 2013
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #18904: Improve os.get/set_inheritable() tests
parent
88983500
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
7 deletions
+29
-7
Lib/test/test_os.py
Lib/test/test_os.py
+29
-7
No files found.
Lib/test/test_os.py
View file @
7ba6b0f9
...
...
@@ -34,6 +34,10 @@ try:
import
resource
except
ImportError
:
resource
=
None
try
:
import
fcntl
except
ImportError
:
fcntl
=
None
from
test.script_helper
import
assert_python_ok
...
...
@@ -2300,19 +2304,37 @@ class CPUCountTests(unittest.TestCase):
class
FDInheritanceTests
(
unittest
.
TestCase
):
def
test_get_inheritable
(
self
):
def
test_get_
set_
inheritable
(
self
):
fd
=
os
.
open
(
__file__
,
os
.
O_RDONLY
)
self
.
addCleanup
(
os
.
close
,
fd
)
for
inheritable
in
(
False
,
True
):
os
.
set_inheritable
(
fd
,
inheritable
)
self
.
assertEqual
(
os
.
get_inheritable
(
fd
),
inheritable
)
self
.
assertEqual
(
os
.
get_inheritable
(
fd
),
False
)
def
test_set_inheritable
(
self
):
fd
=
os
.
open
(
__file__
,
os
.
O_RDONLY
)
self
.
addCleanup
(
os
.
close
,
fd
)
os
.
set_inheritable
(
fd
,
True
)
self
.
assertEqual
(
os
.
get_inheritable
(
fd
),
True
)
if
fcntl
:
def
test_get_inheritable_cloexec
(
self
):
fd
=
os
.
open
(
__file__
,
os
.
O_RDONLY
)
self
.
addCleanup
(
os
.
close
,
fd
)
self
.
assertEqual
(
os
.
get_inheritable
(
fd
),
False
)
# clear FD_CLOEXEC flag
flags
=
fcntl
.
fcntl
(
fd
,
fcntl
.
F_GETFD
)
flags
&=
~
fcntl
.
FD_CLOEXEC
fcntl
.
fcntl
(
fd
,
fcntl
.
F_SETFD
,
flags
)
self
.
assertEqual
(
os
.
get_inheritable
(
fd
),
True
)
def
test_set_inheritable_cloexec
(
self
):
fd
=
os
.
open
(
__file__
,
os
.
O_RDONLY
)
self
.
addCleanup
(
os
.
close
,
fd
)
self
.
assertEqual
(
fcntl
.
fcntl
(
fd
,
fcntl
.
F_GETFD
)
&
fcntl
.
FD_CLOEXEC
,
fcntl
.
FD_CLOEXEC
)
os
.
set_inheritable
(
fd
,
True
)
self
.
assertEqual
(
fcntl
.
fcntl
(
fd
,
fcntl
.
F_GETFD
)
&
fcntl
.
FD_CLOEXEC
,
0
)
def
test_open
(
self
):
fd
=
os
.
open
(
__file__
,
os
.
O_RDONLY
)
self
.
addCleanup
(
os
.
close
,
fd
)
...
...
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