From f9460f25543135e9b436285cbf25e30dc22c57a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=C3=A1n=20Maureira-Fredes?= Date: Wed, 30 Mar 2022 20:48:56 +0200 Subject: flake8: fix style issues on testing Change-Id: I4e3e922ff95040999bc3bb1463c2e29783d5ee14 Reviewed-by: Friedemann Kleint --- testing/__init__.py | 1 + testing/blacklist.py | 5 +++-- testing/buildlog.py | 2 +- testing/command.py | 10 +++++----- testing/helper.py | 1 - testing/parser.py | 2 +- testing/runner.py | 7 +++---- testing/wheel_tester.py | 18 +++++++++--------- testrunner.py | 3 +-- 9 files changed, 24 insertions(+), 25 deletions(-) diff --git a/testing/__init__.py b/testing/__init__.py index ca4e621ce..542ddc8a8 100644 --- a/testing/__init__.py +++ b/testing/__init__.py @@ -46,6 +46,7 @@ testing/__init__.py import builtins import sys + from . import command main = command.main diff --git a/testing/blacklist.py b/testing/blacklist.py index 432eb86ab..6ea104b8f 100644 --- a/testing/blacklist.py +++ b/testing/blacklist.py @@ -46,8 +46,9 @@ find_matching_line() adds info using classifiers. """ from io import StringIO -from .helper import decorate + from .buildlog import builds +from .helper import decorate class BlackList(object): @@ -63,7 +64,7 @@ class BlackList(object): def filtered_line(line): if "#" in line: - line = line[ : line.index("#")] + line = line[:line.index("#")] return line.split() # now put every bracketed line in a test diff --git a/testing/buildlog.py b/testing/buildlog.py index afa09c992..a61a7b475 100644 --- a/testing/buildlog.py +++ b/testing/buildlog.py @@ -47,8 +47,8 @@ BuildLog.classifiers finds the set of classifier strings. import os import platform -import sys import shutil +import sys from collections import namedtuple from textwrap import dedent diff --git a/testing/command.py b/testing/command.py index 00dcb485c..172039adb 100644 --- a/testing/command.py +++ b/testing/command.py @@ -70,18 +70,18 @@ The full mode can be tested locally by setting export COIN_RERUN_FAILED_ONLY=0 """ +import argparse import os import sys -import argparse -from textwrap import dedent from collections import OrderedDict +from textwrap import dedent from timeit import default_timer as timer -from .helper import script_dir, decorate -from .buildlog import builds from .blacklist import BlackList -from .runner import TestRunner +from .buildlog import builds +from .helper import decorate, script_dir from .parser import TestParser +from .runner import TestRunner # Should we repeat only failed tests? COIN_RERUN_FAILED_ONLY = True diff --git a/testing/helper.py b/testing/helper.py index a8d3a65ff..7a9551bfb 100644 --- a/testing/helper.py +++ b/testing/helper.py @@ -45,7 +45,6 @@ Some tools that do not fit elsewhere. import os - script_dir = os.path.dirname(os.path.dirname(__file__)) diff --git a/testing/parser.py b/testing/parser.py index 7e1e6c792..05bfdab8a 100644 --- a/testing/parser.py +++ b/testing/parser.py @@ -129,7 +129,7 @@ def _parse_tests(test_log): match = re.match(pat, line, re.VERBOSE) if match and line.split()[-1] != "sec": # don't change the number of lines - lines[idx : idx + 2] = [line.rstrip() + lines[idx + 1], ""] + lines[idx:idx + 2] = [line.rstrip() + lines[idx + 1], ""] pat = _TEST_PAT for line in lines: diff --git a/testing/runner.py b/testing/runner.py index 50c08d21d..001a84833 100644 --- a/testing/runner.py +++ b/testing/runner.py @@ -37,14 +37,13 @@ ## ############################################################################# +import inspect import os -import sys import re import subprocess -import inspect - -from textwrap import dedent +import sys from subprocess import TimeoutExpired +from textwrap import dedent # Get the dir path to the utils module try: diff --git a/testing/wheel_tester.py b/testing/wheel_tester.py index c97647861..160ef7d37 100644 --- a/testing/wheel_tester.py +++ b/testing/wheel_tester.py @@ -52,11 +52,12 @@ Make sure that some generated wheels already exist in the dist/ directory (e.g. setup.py bdist_wheel was already executed). """ -from argparse import ArgumentParser, RawTextHelpFormatter -from pathlib import Path import os +import platform import sys import tempfile +from argparse import ArgumentParser, RawTextHelpFormatter +from pathlib import Path try: this_file = __file__ @@ -67,17 +68,16 @@ this_dir = os.path.dirname(this_file) setup_script_dir = os.path.abspath(os.path.join(this_dir, "..")) sys.path.append(setup_script_dir) -from build_scripts.utils import find_files_using_glob -from build_scripts.utils import find_glob_in_path -from build_scripts.utils import run_process, run_process_output -from build_scripts.utils import rmtree from setuptools._distutils import log -import platform + +from build_scripts.utils import (find_files_using_glob, find_glob_in_path, + rmtree, run_process, run_process_output) log.set_verbosity(1) NEW_WHEELS = False + def find_executable(executable, command_line_value): value = command_line_value option_str = f"--{executable}" @@ -242,7 +242,7 @@ def run_ninja(): args = ["ninja"] exit_code = run_process(args) if exit_code: - raise RuntimeError(f"Failure while running {executable}.") + raise RuntimeError(f"Failure while running {' '.join(args)}.") log.info("") @@ -250,7 +250,7 @@ def run_ninja_install(): args = ["ninja", "install"] exit_code = run_process(args) if exit_code: - raise RuntimeError(f"Failed while running {executable} install.") + raise RuntimeError(f"Failed while running {' '.join(args)} install.") log.info("") diff --git a/testrunner.py b/testrunner.py index 2b24bc20e..dc7c6f716 100644 --- a/testrunner.py +++ b/testrunner.py @@ -44,8 +44,7 @@ Run ctest on the last build. See the notes in testing/command.py . """ -import sys import testing -import testing.blacklist # just to be sure it's us... +import testing.blacklist # just to be sure it's us... testing.main() -- cgit v1.2.3