diff --git a/src/test/regress/citus_tests/common.py b/src/test/regress/citus_tests/common.py index d8fe9a8ee..1654905cb 100644 --- a/src/test/regress/citus_tests/common.py +++ b/src/test/regress/citus_tests/common.py @@ -6,7 +6,7 @@ import subprocess import sys import utils -from utils import USER, cd +from utils import USER def initialize_temp_dir(temp_dir): @@ -70,8 +70,11 @@ def add_settings(abs_data_path, settings): def create_role(pg_path, node_ports, user_name): def create(port): - command = "SET citus.enable_ddl_propagation TO OFF; SELECT worker_create_or_alter_role('{}', 'CREATE ROLE {} WITH LOGIN CREATEROLE CREATEDB;', NULL)".format( - user_name, user_name + command = ( + "SET citus.enable_ddl_propagation TO OFF;" + + "SELECT worker_create_or_alter_role('{}', 'CREATE ROLE {} WITH LOGIN CREATEROLE CREATEDB;', NULL)".format( + user_name, user_name + ) ) utils.psql(pg_path, port, command) command = "SET citus.enable_ddl_propagation TO OFF; GRANT CREATE ON DATABASE postgres to {}".format( diff --git a/src/test/regress/citus_tests/config.py b/src/test/regress/citus_tests/config.py index 0ee8a1707..7c9cd599a 100644 --- a/src/test/regress/citus_tests/config.py +++ b/src/test/regress/citus_tests/config.py @@ -75,7 +75,7 @@ def find_free_port(): port = next_port next_port += 1 return port - except: + except Exception: next_port += 1 # we couldn't find a port raise Exception("Couldn't find a port to use") diff --git a/src/test/regress/citus_tests/run_test.py b/src/test/regress/citus_tests/run_test.py index 55811f4f8..6ce58d480 100755 --- a/src/test/regress/citus_tests/run_test.py +++ b/src/test/regress/citus_tests/run_test.py @@ -63,7 +63,7 @@ test_files_to_skip = [ test_files_to_run_without_schedule = ["single_node_enterprise"] if not (test_file_name or test_file_path): - print(f"FATAL: No test given.") + print("FATAL: No test given.") sys.exit(2) @@ -77,7 +77,7 @@ if test_file_path: test_file_extension = pathlib.Path(test_file_path).suffix test_file_name = pathlib.Path(test_file_path).stem - if not test_file_extension in ".spec.sql": + if test_file_extension not in ".spec.sql": print( "ERROR: Unrecognized test extension. Valid extensions are: .sql and .spec" ) @@ -142,7 +142,7 @@ tmp_schedule_path = os.path.join( if test_file_name not in test_files_to_run_without_schedule: shutil.copy2(os.path.join(regress_dir, test_schedule), tmp_schedule_path) with open(tmp_schedule_path, "a") as myfile: - for i in range(args["repeat"]): + for _ in range(args["repeat"]): myfile.write(test_schedule_line) # find suitable make recipe diff --git a/src/test/regress/citus_tests/upgrade/citus_upgrade_test.py b/src/test/regress/citus_tests/upgrade/citus_upgrade_test.py index 7e55bb714..d36754d48 100755 --- a/src/test/regress/citus_tests/upgrade/citus_upgrade_test.py +++ b/src/test/regress/citus_tests/upgrade/citus_upgrade_test.py @@ -94,7 +94,7 @@ def remove_citus(tar_path): def remove_tar_files(tar_path): ps = subprocess.Popen(("tar", "tf", tar_path), stdout=subprocess.PIPE) - output = subprocess.check_output(("xargs", "rm", "-v"), stdin=ps.stdout) + subprocess.check_output(("xargs", "rm", "-v"), stdin=ps.stdout) ps.wait() diff --git a/src/test/regress/mitmscripts/fluent.py b/src/test/regress/mitmscripts/fluent.py index f254d1bfa..84ecbd193 100644 --- a/src/test/regress/mitmscripts/fluent.py +++ b/src/test/regress/mitmscripts/fluent.py @@ -8,7 +8,6 @@ import struct import threading import time import traceback -from collections import defaultdict from itertools import count import structs diff --git a/src/test/regress/mitmscripts/structs.py b/src/test/regress/mitmscripts/structs.py index 00208d23a..2be3a6a2e 100644 --- a/src/test/regress/mitmscripts/structs.py +++ b/src/test/regress/mitmscripts/structs.py @@ -8,7 +8,6 @@ from construct import ( Computed, CString, Enum, - FixedSized, GreedyBytes, GreedyRange, Int8ub, @@ -16,10 +15,7 @@ from construct import ( Int16ub, Int32sb, Int32ub, - Pointer, - Probe, RestreamData, - Seek, Struct, Switch, this, @@ -179,7 +175,7 @@ class Query(FrontendMessage): 'COPY public.copy_test_XXXXXX (key, value) FROM STDIN WITH (FORMAT BINARY))' """ result = content - pattern = re.compile("public\.[a-z_]+(?P[0-9]+)") + pattern = re.compile(r"public\.[a-z_]+(?P[0-9]+)") for match in pattern.finditer(content): span = match.span("shardid") replacement = "X" * (span[1] - span[0]) @@ -211,9 +207,9 @@ class Query(FrontendMessage): """ pattern = re.compile( - "assign_distributed_transaction_id\s*\(" # a method call - "\s*[0-9]+\s*," # an integer first parameter - "\s*(?P[0-9]+)" # an integer second parameter + r"assign_distributed_transaction_id\s*\(" # a method call + r"\s*[0-9]+\s*," # an integer first parameter + r"\s*(?P[0-9]+)" # an integer second parameter ) result = content for match in pattern.finditer(content):