From 3b7e60e6cbdef596701c1921257ea9e48076eec3 Mon Sep 17 00:00:00 2001 From: Bastian Venthur Date: Wed, 31 Oct 2018 12:32:00 +0100 Subject: [PATCH] Fixed stderr/-out/-in redirection. (#145) Closes: #137 --- dotenv/main.py | 13 ++----------- tests/test_cli.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/dotenv/main.py b/dotenv/main.py index 14bee3b4..349ec069 100644 --- a/dotenv/main.py +++ b/dotenv/main.py @@ -7,7 +7,7 @@ import os import re import sys -from subprocess import Popen, PIPE, STDOUT +from subprocess import Popen import warnings from collections import OrderedDict @@ -293,19 +293,10 @@ def run_command(command, env): cmd_env.update(env) p = Popen(command, - stdin=PIPE, - stdout=PIPE, - stderr=STDOUT, universal_newlines=True, bufsize=0, shell=False, env=cmd_env) - try: - out, _ = p.communicate() - print(out) - except Exception: - warnings.warn('An error occured, running the command:') - out, _ = p.communicate() - warnings.warn(out) + _, _ = p.communicate() return p.returncode diff --git a/tests/test_cli.py b/tests/test_cli.py index 6c9187ec..15c47af8 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -210,10 +210,14 @@ def test_run(cli): assert result == 'BAR' -def test_run_with_other_env(cli, dotenv_file): - cli.invoke(dotenv_cli, ['--file', dotenv_file, 'set', 'FOO', "BAR"]) - result = cli.invoke(dotenv_cli, ['--file', dotenv_file, 'run', 'printenv', 'FOO']) - assert result.output.strip() == 'BAR' +def test_run_with_other_env(cli): + DOTENV_FILE = 'dotenv' + with cli.isolated_filesystem(): + sh.cd(here) + sh.touch(DOTENV_FILE) + sh.dotenv('--file', DOTENV_FILE, 'set', 'FOO', 'BAR') + result = sh.dotenv('--file', DOTENV_FILE, 'run', 'printenv', 'FOO').strip() + assert result == 'BAR' def test_run_without_cmd(cli):