sandbox: tests - close stdout of p1

p1.stdout should be closed after it's connected to p2 according to
https://docs.python.org/3/library/subprocess.html#replacing-shell-pipeline

Fixes:
$ make PYTHON=python3 test
Verify that we can read file descriptors handed to sandbox ...
/usr/lib64/python3.5/unittest/case.py:638: ResourceWarning: unclosed
file <_io.BufferedReader name=4>
  testMethod()

Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
This commit is contained in:
Petr Lautrbach 2016-09-15 16:39:28 +02:00 committed by Stephen Smalley
parent 3aedecefc7
commit 6fcef9a09c

View File

@ -28,6 +28,7 @@ class SandboxTests(unittest.TestCase):
"Verify that we can read file descriptors handed to sandbox"
p1 = Popen(['cat', '/etc/passwd'], stdout=PIPE)
p2 = Popen([sys.executable, 'sandbox', 'grep', 'root'], stdin=p1.stdout, stdout=PIPE)
p1.stdout.close()
out, err = p2.communicate()
self.assertTrue(b'root' in out)