From b71120e71dade9e0c663122a087fcbeb2b348cc4 Mon Sep 17 00:00:00 2001 From: Marcus Ottosson Date: Thu, 14 Dec 2023 16:07:14 +0000 Subject: [PATCH] Re-repair tests for 2019 --- cmdx.py | 11 +++++++++-- run_tests.py | 6 ++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cmdx.py b/cmdx.py index 2cee3d7..5ab6361 100644 --- a/cmdx.py +++ b/cmdx.py @@ -180,6 +180,13 @@ def function(): """ + try: + perf_counter = time_.perf_counter + + # Python 2.7 + except AttributeError: + perf_counter = time_.clock + def timings_decorator(func): if not TIMINGS: # Do not wrap the function. @@ -188,12 +195,12 @@ def timings_decorator(func): @wraps(func) def func_wrapper(*args, **kwargs): - t0 = time_.perf_counter() + t0 = perf_counter() try: return func(*args, **kwargs) finally: - t1 = time_.perf_counter() + t1 = perf_counter() duration = (t1 - t0) * 10 ** 6 # microseconds Stats.LastTiming = duration diff --git a/run_tests.py b/run_tests.py index f4e9db4..8d53284 100644 --- a/run_tests.py +++ b/run_tests.py @@ -6,8 +6,8 @@ import flaky.flaky_nose_plugin as flaky # For nose -if sys.version_info[0] == 3: - import collections +import collections +if not hasattr(collections, "Callable"): collections.Callable = collections.abc.Callable @@ -34,8 +34,6 @@ "cmdx.py", ]) - cmds.colorManagementPrefs(cmEnabled=False, edit=True) - result = nose.main( argv=argv, addplugins=[flaky.FlakyPlugin()],