Skip to content

Commit 7e99e5c

Browse files
author
Peter Amstutz
committed
Use sys.stderr.isatty() to tweak output behavior depending on whether it is
printing to a terminal or not.
1 parent e16102b commit 7e99e5c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cwltest/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ def run_test(args, i, tests): # type: (argparse.Namespace, int, List[Dict[str,
154154
outdir = outstr = outerr = test_command = None
155155
duration = 0.0
156156
t = tests[i]
157+
prefix = ""
158+
suffix = ""
159+
if sys.stderr.isatty():
160+
prefix = "\r"
161+
else:
162+
suffix = "\n"
157163
try:
158164
test_command = [args.tool]
159165
test_command.extend(args.args)
@@ -169,7 +175,7 @@ def run_test(args, i, tests): # type: (argparse.Namespace, int, List[Dict[str,
169175
if t.get("job"):
170176
test_command.append(t["job"])
171177

172-
sys.stderr.write("\rTest [%i/%i] " % (i + 1, len(tests)))
178+
sys.stderr.write("%sTest [%i/%i] %s" % (prefix, i + 1, len(tests), suffix))
173179
sys.stderr.flush()
174180

175181
start_time = time.time()

0 commit comments

Comments
 (0)