File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
tests/tests_e3/os/process Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
2
import sys
3
+ import subprocess
3
4
import textwrap
4
5
import time
5
6
17
18
psutil = None
18
19
19
20
21
+ def test_run_stdout_stderr ():
22
+ """Check Run with partial redirection.
23
+
24
+ Verify that Run is working when stdout is redirected to a file and
25
+ stderr not redirected to stdout.
26
+ """
27
+ prog_filename = os .path .join (os .getcwd (), "prog" )
28
+ with open (prog_filename , "wb" ) as f :
29
+ f .write (b"import sys\n " )
30
+ f .write (b'print("stdout", file=sys.stdout)\n ' )
31
+ f .write (b'print("stderr", file=sys.stderr)\n ' )
32
+ e3 .os .fs .chmod ("a+x" , prog_filename )
33
+ p = e3 .os .process .Run ([sys .executable , prog_filename ], error = subprocess .PIPE )
34
+ assert p .out .replace ("\r " , "" ) == "stdout\n "
35
+ assert p .err .replace ("\r " , "" ) == "stderr\n "
36
+ p = e3 .os .process .Run (
37
+ [sys .executable , prog_filename ], output = "text.txt" , error = subprocess .PIPE
38
+ )
39
+ assert os .path .isfile ("text.txt" )
40
+ assert p .err .replace ("\r " , "" ) == "stderr\n "
41
+
42
+
20
43
def test_run_shebang (caplog ):
21
44
"""Verify that the parse shebang option works."""
22
45
prog_filename = os .path .join (os .getcwd (), "prog" )
You can’t perform that action at this time.
0 commit comments