8000 Revert "move test code to another file" · python/cpython@b9d3a34 · GitHub
[go: up one dir, main page]

Skip to content

Commit b9d3a34

Browse files
committed
Revert "move test code to another file"
This reverts commit 1d45196.
1 parent 84c4b8c commit b9d3a34

File tree

2 files changed

+18
-24
lines changed

2 files changed

+18
-24
lines changed

Lib/test/namespaces-test.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

Lib/test/test_posix.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,9 +2176,9 @@ class NamespacesTests(unittest.TestCase):
21762176
"""Tests for os.unshare() and os.setns()."""
21772177

21782178
@support.requires_subprocess()
2179-
def subprocess(self, file_path):
2179+
def subprocess(self, code):
21802180
import subprocess
2181-
with subprocess.Popen((sys.executable, file_path),
2181+
with subprocess.Popen((sys.executable, '-c', code),
21822182
stdout=subprocess.PIPE,
21832183
stderr=subprocess.PIPE,
21842184
encoding="utf-8"
@@ -2195,7 +2195,22 @@ def subprocess(self, file_path):
21952195
@unittest.skipUnless(os.path.exists('/proc/self/ns/uts'), 'need /proc/self/ns/uts')
21962196
@support.requires_linux_version(3, 0, 0)
21972197
def test_unshare_setns(self):
2198-
rc, out, err = self.subprocess(support.findfile("namespaces-test.py"))
2198+
rc, out, err = self.subprocess("""if 1:
2199+
import os
2200+
import sys
2201+
fd = os.open('/proc/self/ns/uts', os.O_RDONLY)
2202+
try:
2203+
print(os.readlink('/proc/self/ns/uts'))
2204+
os.unshare(os.CLONE_NEWUTS)
2205+
print(os.readlink('/proc/self/ns/uts'))
2206+
os.setns(fd, os.CLONE_NEWUTS)
2207+
print(os.readlink('/proc/self/ns/uts'))
2208+
except OSError as e:
2209+
sys.stderr.write(str(e.errno))
2210+
sys.exit(2)
2211+
finally:
2212+
os.close(fd)
2213+
""")
21992214

22002215
if rc == 2:
22012216
e = int(err[0])

0 commit comments

Comments
 (0)
0