diff --git a/tests-extra/runtests.py b/tests-extra/runtests.py index 8d031eaea..4e705423d 100755 --- a/tests-extra/runtests.py +++ b/tests-extra/runtests.py @@ -27,14 +27,10 @@ outs_dir = None def nothing(): pass -def clear_line(): - if sys.stdout.isatty(): - print("\r\x1b[K", end='') - def progress_print(cntr, lock, func = nothing, *args, **kwargs): if sys.stdout.isatty(): lock.acquire() - clear_line() + dnstest.utils.clear_line() func(*args, **kwargs) print(f"(Processed tests {cntr}/{TASK_COUNT})", end='', flush=True) lock.release() @@ -380,7 +376,7 @@ def main(args): msg_skips = ", SKIPPED: %i" % skip_cnt if skip_cnt > 0 else "" msg_res = ", FAILED: %i" % fail_cnt if fail_cnt > 0 else ", SUCCESS" - clear_line() + dnstest.utils.clear_line() log.info(msg_time + msg_cases + msg_skips + msg_res) if fail_cnt: diff --git a/tests-extra/tools/dnstest/test.py b/tests-extra/tools/dnstest/test.py index 0facf6063..7f868284c 100644 --- a/tests-extra/tools/dnstest/test.py +++ b/tests-extra/tools/dnstest/test.py @@ -349,6 +349,7 @@ class Test(object): time.sleep(seconds) def pause(self, msg=None): + clear_line() input(test_info() + ((", " + msg) if msg else "")) def rel_sleep(self, seconds): diff --git a/tests-extra/tools/dnstest/utils.py b/tests-extra/tools/dnstest/utils.py index d8a2eab80..25375d66a 100644 --- a/tests-extra/tools/dnstest/utils.py +++ b/tests-extra/tools/dnstest/utils.py @@ -4,6 +4,7 @@ import enum import inspect import os import re +import sys import time from dnstest.context import Context @@ -139,3 +140,7 @@ def compare_sections(section1, srv1name, section2, srv2name, name): if different: detail_log(SEP) + +def clear_line(): + if sys.stdout.isatty(): + print("\r\x1b[K", end='')