tests: make whitespace between functions and classes consistent
No binary (build failed)
—
(log yok)
| @@ -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 "$@" |
| @@ -40,6 +40,7 @@ try: # Python 2 | |
| except ImportError: # Python 3 | |
| import socketserver | |
| + | |
| log = logging.getLogger(__name__) | |
| HOST = "localhost" | |
| @@ -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' ] | |
| @@ -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 | |
| @@ -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: | |
| @@ -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 "<unknown>" | |
| + | |
| 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() | |
| @@ -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. | |
| @@ -31,6 +31,7 @@ log = logging.getLogger(__name__) | |
| REPLY_DATA = re.compile("<reply>[ \t\n\r]*<data[^<]*>(.*?)</data>", 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) | |