From 0eab2fb9fd2006356c12830145fac067f64f7f8a Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 18 Jun 2026 15:21:12 +0200 Subject: workflows/ci: add Python linting --- test/src/conftest.py | 3 +-- test/src/lib/test_repo.py | 16 +++++++++++++--- test/src/lib/tests.py | 6 ++++-- test/src/test_repo.py | 19 ++++++++++++------- 4 files changed, 30 insertions(+), 14 deletions(-) (limited to 'test/src') diff --git a/test/src/conftest.py b/test/src/conftest.py index 6c34f4d..029eeb7 100644 --- a/test/src/conftest.py +++ b/test/src/conftest.py @@ -157,8 +157,7 @@ def server(server_cmd): @fixture def workers(worker_cmd): - with worker_cmd.run_async() as worker1, \ - worker_cmd.run_async() as worker2: + with worker_cmd.run_async() as worker1, worker_cmd.run_async() as worker2: yield [worker1, worker2] assert worker1.returncode == 0 assert worker2.returncode == 0 diff --git a/test/src/lib/test_repo.py b/test/src/lib/test_repo.py index 0356ad8..f295e91 100644 --- a/test/src/lib/test_repo.py +++ b/test/src/lib/test_repo.py @@ -76,7 +76,13 @@ class TestRepo(Repo): return CI_SCRIPT.format(runs_dir=runs_dir) def _count_run_files(self): - return len([name for name in os.listdir(self.runs_dir) if os.path.isfile(os.path.join(self.runs_dir, name))]) + return len( + [ + name + for name in os.listdir(self.runs_dir) + if os.path.isfile(os.path.join(self.runs_dir, name)) + ] + ) def run_files_are_present(self, expected): assert expected == self._count_run_files() @@ -98,7 +104,8 @@ class TestRepoOutput(TestRepo, abc.ABC): def format_ci_script(self): script = super().format_ci_script() added = r'{output_script} | tee -a "$run_output_path"'.format( - output_script=shlex.quote(self.output_script_path)) + output_script=shlex.quote(self.output_script_path) + ) return f'{script}\n{added}\n' def write_output_script(self): @@ -226,7 +233,10 @@ class TestRepoSegfault(TestRepo): def run_output_matches(self, output): output = output.decode() - return output.startswith("Started the test program.\n") and "You shouldn't see this." not in output + return ( + output.startswith("Started the test program.\n") + and "You shouldn't see this." not in output + ) def run_files_are_present(self, *args): return True diff --git a/test/src/lib/tests.py b/test/src/lib/tests.py index 7ccedef..b20ecc5 100644 --- a/test/src/lib/tests.py +++ b/test/src/lib/tests.py @@ -14,8 +14,10 @@ def my_parametrize(names, values, ids=None, **kwargs): if len(_names) == 1: ids = [f'{names}={v}' for v in values] else: - _values = [combination.values if hasattr(combination, 'values') else combination - for combination in values] + _values = [ + combination.values if hasattr(combination, 'values') else combination + for combination in values + ] ids = [ '-'.join(f'{k}={v}' for k, v in zip(_names, combination)) for combination in _values diff --git a/test/src/test_repo.py b/test/src/test_repo.py index eb717cb..ef45103 100644 --- a/test/src/test_repo.py +++ b/test/src/test_repo.py @@ -55,7 +55,10 @@ def _test_repo_internal(env, repo, numof_processes, runs_per_process): with child_logging_thread() as log_queue: ctx = mp.get_context('spawn') args = (log_queue, env.client, runs_per_process, repo) - processes = [ctx.Process(target=client_runner_process, args=args) for i in range(numof_processes)] + processes = [ + ctx.Process(target=client_runner_process, args=args) + for i in range(numof_processes) + ] for proc in processes: proc.start() @@ -94,12 +97,14 @@ def test_repo(env, test_repo, numof_clients, runs_per_client): @pytest.mark.stress -@my_parametrize('numof_clients,runs_per_client', - [ - (10, 50), - (1, 2000), - (4, 500), - ]) +@my_parametrize( + 'numof_clients,runs_per_client', + [ + (10, 50), + (1, 2000), + (4, 500), + ], +) def test_repo_stress(env, stress_test_repo, numof_clients, runs_per_client): _test_repo_internal(env, stress_test_repo, numof_clients, runs_per_client) -- cgit v1.3