From 84c2852a0906be226917df1dafb50c539180893d Mon Sep 17 00:00:00 2001 From: Maxime Liquet <35924738+maximlt@users.noreply.github.com> Date: Wed, 8 Nov 2023 13:09:05 +0100 Subject: [PATCH] set creationflags on Windows only (#886) --- param/version.py | 5 ++++- tests/testversion.py | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/testversion.py diff --git a/param/version.py b/param/version.py index 9884491e..ed863740 100644 --- a/param/version.py +++ b/param/version.py @@ -21,10 +21,13 @@ import os, subprocess, json def run_cmd(args, cwd=None): + kwargs = {} + if os.name == 'nt': + kwargs['creationflags'] = subprocess.CREATE_NO_WINDOW proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd, - creationflags=subprocess.CREATE_NO_WINDOW) + **kwargs) output, error = (str(s.decode()).strip() for s in proc.communicate()) # Detects errors as _either_ a non-zero return code _or_ messages diff --git a/tests/testversion.py b/tests/testversion.py new file mode 100644 index 00000000..1a71f673 --- /dev/null +++ b/tests/testversion.py @@ -0,0 +1,6 @@ +from param.version import run_cmd + + +def test_run_cmd(): + output = run_cmd(['echo', 'test']) + assert output == 'test'