From: Dan Fandrich Date: Sun, 5 Apr 2026 16:00:55 +0000 (-0700) Subject: tests: make whitespace between functions and classes consistent X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17e8200733a1fd9db148f794d7e1cfb47e491fcd;p=thirdparty%2Fcurl.git tests: make whitespace between functions and classes consistent Mostly, this means two blank lines between classes and functions and one line between methods. Since these checks are currently in preview, they are done in a separate ruff invocation to avoid turning ALL the preview checks on at the same time. --- diff --git a/scripts/pythonlint.sh b/scripts/pythonlint.sh index 0164821548..5c1a3cdcc3 100755 --- a/scripts/pythonlint.sh +++ b/scripts/pythonlint.sh @@ -31,3 +31,5 @@ ruff check --extend-select=B007,B016,C405,C416,COM818,D200,D213,D204,D401,\ D415,FURB129,N818,PERF401,PERF403,PIE790,PIE808,PLW0127,Q004,RUF010,SIM101,\ SIM117,SIM118,TRY400,TRY401,RET503,RET504,UP004,B018,B904,RSE102,RET505,I001 \ "$@" +# Checks that are in preview only, since --preview otherwise turns them all on +ruff check --preview --select=E301,E302,E303,E304,E305,E306,E502 "$@" diff --git a/tests/dictserver.py b/tests/dictserver.py index 8dc33cd0dc..b4e1afd78b 100755 --- a/tests/dictserver.py +++ b/tests/dictserver.py @@ -40,6 +40,7 @@ try: # Python 2 except ImportError: # Python 3 import socketserver + log = logging.getLogger(__name__) HOST = "localhost" diff --git a/tests/ech_combos.py b/tests/ech_combos.py index 4eba4de1c2..8c100c2bb7 100755 --- a/tests/ech_combos.py +++ b/tests/ech_combos.py @@ -72,6 +72,7 @@ def CombinationRepetitionUtil(chosen, arr, badarr, index, CombinationRepetitionUtil(chosen, arr, badarr, index, r, start + 1, end) + # The main function that prints all # combinations of size r in arr[] of # size n. This function mainly uses @@ -86,6 +87,7 @@ def CombinationRepetition(arr, badarr, n, r): # temporary array 'chosen[]' CombinationRepetitionUtil(chosen, arr, badarr, 0, r, 0, n) + # Driver code badarr = [ '--ech grease', '--ech false', '--ech ecl:$badecl', '--ech pn:$badpn' ] goodarr = [ '--ech hard', '--ech true', '--ech ecl:$goodecl', '--ech pn:$goodpn' ] diff --git a/tests/http/conftest.py b/tests/http/conftest.py index dddcdc3279..08da73ac0f 100644 --- a/tests/http/conftest.py +++ b/tests/http/conftest.py @@ -148,11 +148,13 @@ def configures_httpd(env, httpd) -> Generator[bool, None, None]: # include this fixture as test parameter if the test configures httpd itself yield True + @pytest.fixture(scope='session') def configures_nghttpx(env, httpd) -> Generator[bool, None, None]: # include this fixture as test parameter if the test configures nghttpx itself yield True + @pytest.fixture(autouse=True, scope='function') def server_reset(request, env, httpd, nghttpx): # make sure httpd is in default configuration when a test starts diff --git a/tests/http/scorecard.py b/tests/http/scorecard.py index e5e9e26292..205b556f61 100644 --- a/tests/http/scorecard.py +++ b/tests/http/scorecard.py @@ -763,7 +763,6 @@ def run_score(args, protocol): for x in args.request_parallels: request_parallels.extend([int(s) for s in x.split(',')]) - if args.downloads or args.uploads or args.requests or args.handshakes: handshakes = args.handshakes if not args.downloads: diff --git a/tests/negtelnetserver.py b/tests/negtelnetserver.py index 34be28182b..c31fc033aa 100755 --- a/tests/negtelnetserver.py +++ b/tests/negtelnetserver.py @@ -38,6 +38,7 @@ if sys.version_info.major >= 3: else: import SocketServer as socketserver + log = logging.getLogger(__name__) HOST = "localhost" IDENT = "NTEL" @@ -46,6 +47,7 @@ IDENT = "NTEL" VERIFIED_REQ = "verifiedserver" VERIFIED_RSP = "WE ROOLZ: {pid}" + def telnetserver(options): """Start up a TCP server with a telnet handler and serve DICT requests forever.""" if options.pidfile: @@ -66,6 +68,7 @@ def telnetserver(options): # leaving `with` calls server.close() automatically return ScriptRC.SUCCESS + class NegotiatingTelnetHandler(socketserver.BaseRequestHandler): """Handler class for Telnet connections.""" @@ -109,6 +112,7 @@ class NegotiatingTelnetHandler(socketserver.BaseRequestHandler): except IOError: log.exception("IOError hit during request") + class Negotiator: NO_NEG = 0 START_NEG = 1 @@ -237,6 +241,7 @@ class Negotiator: log.debug("Sending WONT %s", option_str) self.send_iac([NegTokens.WONT, NegOptions.to_val(option_str)]) + class NegBase: @classmethod def to_val(cls, name): @@ -250,6 +255,7 @@ class NegBase: return "" + class NegTokens(NegBase): # The start of a negotiation sequence IAC = 255 @@ -267,6 +273,7 @@ class NegTokens(NegBase): # The end of sub-negotiation options. SE = 240 + class NegOptions(NegBase): # Binary Transmission BINARY = 0 @@ -279,6 +286,7 @@ class NegOptions(NegBase): # Charset option CHARSET = 42 + def get_options(): parser = argparse.ArgumentParser() @@ -297,6 +305,7 @@ def get_options(): return parser.parse_args() + def setup_logging(options): """Set up logging from the command line options.""" root_logger = logging.getLogger() @@ -329,6 +338,7 @@ def setup_logging(options): stdout_handler.setLevel(logging.DEBUG) root_logger.addHandler(stdout_handler) + class ScriptRC: """Enum for script return codes.""" @@ -336,6 +346,7 @@ class ScriptRC: FAILURE = 1 EXCEPTION = 2 + if __name__ == '__main__': # Get the options from the user. options = get_options() diff --git a/tests/smbserver.py b/tests/smbserver.py index 34d3dabc00..c294207988 100755 --- a/tests/smbserver.py +++ b/tests/smbserver.py @@ -43,6 +43,7 @@ except ImportError: 'Warning: Python package impacket is required for smb testing; ' 'use pip or your package manager to install it\n') sys.exit(1) + from impacket import smb as imp_smb from impacket import smbserver as imp_smbserver from impacket.nt_errors import STATUS_ACCESS_DENIED, STATUS_NO_SUCH_FILE, STATUS_SUCCESS @@ -53,6 +54,7 @@ TESTS_MAGIC = "TESTS_MAGIC" VERIFIED_REQ = "verifiedserver" VERIFIED_RSP = "WE ROOLZ: {pid}\n" + class ShutdownHandler(threading.Thread): """ Cleanly shut down the SMB server. diff --git a/tests/util.py b/tests/util.py index 942a590a8f..7db47d0a00 100755 --- a/tests/util.py +++ b/tests/util.py @@ -31,6 +31,7 @@ log = logging.getLogger(__name__) REPLY_DATA = re.compile("[ \t\n\r]*(.*?)", re.MULTILINE | re.DOTALL) + class ClosingFileHandler(logging.StreamHandler): def __init__(self, filename): super(ClosingFileHandler, self).__init__() @@ -59,6 +60,7 @@ class ClosingFileHandler(logging.StreamHandler): self.release() return result + class TestData: def __init__(self, data_folder): self.data_folder = data_folder @@ -80,6 +82,7 @@ class TestData: # Left-strip the data so we do not get a newline before our data. return m.group(1).lstrip() + if __name__ == '__main__': td = TestData("./data") data = td.get_test_data(1451)