Skip to content

Commit 3b7e60e

Browse files
venthurtheskumar
authored andcommitted
Fixed stderr/-out/-in redirection. (theskumar#145)
Closes: theskumar#137
1 parent 43af2c5 commit 3b7e60e

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

dotenv/main.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import os
88
import re
99
import sys
10-
from subprocess import Popen, PIPE, STDOUT
10+
from subprocess import Popen
1111
import warnings
1212
from collections import OrderedDict
1313

@@ -293,19 +293,10 @@ def run_command(command, env):
293293
cmd_env.update(env)
294294

295295
p = Popen(command,
296-
stdin=PIPE,
297-
stdout=PIPE,
298-
stderr=STDOUT,
299296
universal_newlines=True,
300297
bufsize=0,
301298
shell=False,
302299
env=cmd_env)
303-
try:
304-
out, _ = p.communicate()
305-
print(out)
306-
except Exception:
307-
warnings.warn('An error occured, running the command:')
308-
out, _ = p.communicate()
309-
warnings.warn(out)
300+
_, _ = p.communicate()
310301

311302
return p.returncode

tests/test_cli.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,14 @@ def test_run(cli):
210210
assert result == 'BAR'
211211

212212

213-
def test_run_with_other_env(cli, dotenv_file):
214-
cli.invoke(dotenv_cli, ['--file', dotenv_file, 'set', 'FOO', "BAR"])
215-
result = cli.invoke(dotenv_cli, ['--file', dotenv_file, 'run', 'printenv', 'FOO'])
216-
assert result.output.strip() == 'BAR'
213+
def test_run_with_other_env(cli):
214+
DOTENV_FILE = 'dotenv'
215+
with cli.isolated_filesystem():
216+
sh.cd(here)
217+
sh.touch(DOTENV_FILE)
218+
sh.dotenv('--file', DOTENV_FILE, 'set', 'FOO', 'BAR')
219+
result = sh.dotenv('--file', DOTENV_FILE, 'run', 'printenv', 'FOO').strip()
220+
assert result == 'BAR'
217221

218222

219223
def test_run_without_cmd(cli):

0 commit comments

Comments
 (0)