mirror of
https://github.com/curl/curl.git
synced 2026-04-14 22:31:41 +03:00
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.
This commit is contained in:
parent
98e470b3a8
commit
17e8200733
8 changed files with 23 additions and 1 deletions
|
|
@ -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,\
|
D415,FURB129,N818,PERF401,PERF403,PIE790,PIE808,PLW0127,Q004,RUF010,SIM101,\
|
||||||
SIM117,SIM118,TRY400,TRY401,RET503,RET504,UP004,B018,B904,RSE102,RET505,I001 \
|
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
|
except ImportError: # Python 3
|
||||||
import socketserver
|
import socketserver
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
HOST = "localhost"
|
HOST = "localhost"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ def CombinationRepetitionUtil(chosen, arr, badarr, index,
|
||||||
CombinationRepetitionUtil(chosen, arr, badarr, index,
|
CombinationRepetitionUtil(chosen, arr, badarr, index,
|
||||||
r, start + 1, end)
|
r, start + 1, end)
|
||||||
|
|
||||||
|
|
||||||
# The main function that prints all
|
# The main function that prints all
|
||||||
# combinations of size r in arr[] of
|
# combinations of size r in arr[] of
|
||||||
# size n. This function mainly uses
|
# size n. This function mainly uses
|
||||||
|
|
@ -86,6 +87,7 @@ def CombinationRepetition(arr, badarr, n, r):
|
||||||
# temporary array 'chosen[]'
|
# temporary array 'chosen[]'
|
||||||
CombinationRepetitionUtil(chosen, arr, badarr, 0, r, 0, n)
|
CombinationRepetitionUtil(chosen, arr, badarr, 0, r, 0, n)
|
||||||
|
|
||||||
|
|
||||||
# Driver code
|
# Driver code
|
||||||
badarr = [ '--ech grease', '--ech false', '--ech ecl:$badecl', '--ech pn:$badpn' ]
|
badarr = [ '--ech grease', '--ech false', '--ech ecl:$badecl', '--ech pn:$badpn' ]
|
||||||
goodarr = [ '--ech hard', '--ech true', '--ech ecl:$goodecl', '--ech pn:$goodpn' ]
|
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
|
# include this fixture as test parameter if the test configures httpd itself
|
||||||
yield True
|
yield True
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def configures_nghttpx(env, httpd) -> Generator[bool, None, None]:
|
def configures_nghttpx(env, httpd) -> Generator[bool, None, None]:
|
||||||
# include this fixture as test parameter if the test configures nghttpx itself
|
# include this fixture as test parameter if the test configures nghttpx itself
|
||||||
yield True
|
yield True
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True, scope='function')
|
@pytest.fixture(autouse=True, scope='function')
|
||||||
def server_reset(request, env, httpd, nghttpx):
|
def server_reset(request, env, httpd, nghttpx):
|
||||||
# make sure httpd is in default configuration when a test starts
|
# 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:
|
for x in args.request_parallels:
|
||||||
request_parallels.extend([int(s) for s in x.split(',')])
|
request_parallels.extend([int(s) for s in x.split(',')])
|
||||||
|
|
||||||
|
|
||||||
if args.downloads or args.uploads or args.requests or args.handshakes:
|
if args.downloads or args.uploads or args.requests or args.handshakes:
|
||||||
handshakes = args.handshakes
|
handshakes = args.handshakes
|
||||||
if not args.downloads:
|
if not args.downloads:
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ if sys.version_info.major >= 3:
|
||||||
else:
|
else:
|
||||||
import SocketServer as socketserver
|
import SocketServer as socketserver
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
HOST = "localhost"
|
HOST = "localhost"
|
||||||
IDENT = "NTEL"
|
IDENT = "NTEL"
|
||||||
|
|
@ -46,6 +47,7 @@ IDENT = "NTEL"
|
||||||
VERIFIED_REQ = "verifiedserver"
|
VERIFIED_REQ = "verifiedserver"
|
||||||
VERIFIED_RSP = "WE ROOLZ: {pid}"
|
VERIFIED_RSP = "WE ROOLZ: {pid}"
|
||||||
|
|
||||||
|
|
||||||
def telnetserver(options):
|
def telnetserver(options):
|
||||||
"""Start up a TCP server with a telnet handler and serve DICT requests forever."""
|
"""Start up a TCP server with a telnet handler and serve DICT requests forever."""
|
||||||
if options.pidfile:
|
if options.pidfile:
|
||||||
|
|
@ -66,6 +68,7 @@ def telnetserver(options):
|
||||||
# leaving `with` calls server.close() automatically
|
# leaving `with` calls server.close() automatically
|
||||||
return ScriptRC.SUCCESS
|
return ScriptRC.SUCCESS
|
||||||
|
|
||||||
|
|
||||||
class NegotiatingTelnetHandler(socketserver.BaseRequestHandler):
|
class NegotiatingTelnetHandler(socketserver.BaseRequestHandler):
|
||||||
"""Handler class for Telnet connections."""
|
"""Handler class for Telnet connections."""
|
||||||
|
|
||||||
|
|
@ -109,6 +112,7 @@ class NegotiatingTelnetHandler(socketserver.BaseRequestHandler):
|
||||||
except IOError:
|
except IOError:
|
||||||
log.exception("IOError hit during request")
|
log.exception("IOError hit during request")
|
||||||
|
|
||||||
|
|
||||||
class Negotiator:
|
class Negotiator:
|
||||||
NO_NEG = 0
|
NO_NEG = 0
|
||||||
START_NEG = 1
|
START_NEG = 1
|
||||||
|
|
@ -237,6 +241,7 @@ class Negotiator:
|
||||||
log.debug("Sending WONT %s", option_str)
|
log.debug("Sending WONT %s", option_str)
|
||||||
self.send_iac([NegTokens.WONT, NegOptions.to_val(option_str)])
|
self.send_iac([NegTokens.WONT, NegOptions.to_val(option_str)])
|
||||||
|
|
||||||
|
|
||||||
class NegBase:
|
class NegBase:
|
||||||
@classmethod
|
@classmethod
|
||||||
def to_val(cls, name):
|
def to_val(cls, name):
|
||||||
|
|
@ -250,6 +255,7 @@ class NegBase:
|
||||||
|
|
||||||
return "<unknown>"
|
return "<unknown>"
|
||||||
|
|
||||||
|
|
||||||
class NegTokens(NegBase):
|
class NegTokens(NegBase):
|
||||||
# The start of a negotiation sequence
|
# The start of a negotiation sequence
|
||||||
IAC = 255
|
IAC = 255
|
||||||
|
|
@ -267,6 +273,7 @@ class NegTokens(NegBase):
|
||||||
# The end of sub-negotiation options.
|
# The end of sub-negotiation options.
|
||||||
SE = 240
|
SE = 240
|
||||||
|
|
||||||
|
|
||||||
class NegOptions(NegBase):
|
class NegOptions(NegBase):
|
||||||
# Binary Transmission
|
# Binary Transmission
|
||||||
BINARY = 0
|
BINARY = 0
|
||||||
|
|
@ -279,6 +286,7 @@ class NegOptions(NegBase):
|
||||||
# Charset option
|
# Charset option
|
||||||
CHARSET = 42
|
CHARSET = 42
|
||||||
|
|
||||||
|
|
||||||
def get_options():
|
def get_options():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
|
|
@ -297,6 +305,7 @@ def get_options():
|
||||||
|
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def setup_logging(options):
|
def setup_logging(options):
|
||||||
"""Set up logging from the command line options."""
|
"""Set up logging from the command line options."""
|
||||||
root_logger = logging.getLogger()
|
root_logger = logging.getLogger()
|
||||||
|
|
@ -329,6 +338,7 @@ def setup_logging(options):
|
||||||
stdout_handler.setLevel(logging.DEBUG)
|
stdout_handler.setLevel(logging.DEBUG)
|
||||||
root_logger.addHandler(stdout_handler)
|
root_logger.addHandler(stdout_handler)
|
||||||
|
|
||||||
|
|
||||||
class ScriptRC:
|
class ScriptRC:
|
||||||
"""Enum for script return codes."""
|
"""Enum for script return codes."""
|
||||||
|
|
||||||
|
|
@ -336,6 +346,7 @@ class ScriptRC:
|
||||||
FAILURE = 1
|
FAILURE = 1
|
||||||
EXCEPTION = 2
|
EXCEPTION = 2
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Get the options from the user.
|
# Get the options from the user.
|
||||||
options = get_options()
|
options = get_options()
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ except ImportError:
|
||||||
'Warning: Python package impacket is required for smb testing; '
|
'Warning: Python package impacket is required for smb testing; '
|
||||||
'use pip or your package manager to install it\n')
|
'use pip or your package manager to install it\n')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
from impacket import smb as imp_smb
|
from impacket import smb as imp_smb
|
||||||
from impacket import smbserver as imp_smbserver
|
from impacket import smbserver as imp_smbserver
|
||||||
from impacket.nt_errors import STATUS_ACCESS_DENIED, STATUS_NO_SUCH_FILE, STATUS_SUCCESS
|
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_REQ = "verifiedserver"
|
||||||
VERIFIED_RSP = "WE ROOLZ: {pid}\n"
|
VERIFIED_RSP = "WE ROOLZ: {pid}\n"
|
||||||
|
|
||||||
|
|
||||||
class ShutdownHandler(threading.Thread):
|
class ShutdownHandler(threading.Thread):
|
||||||
"""
|
"""
|
||||||
Cleanly shut down the SMB server.
|
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)
|
REPLY_DATA = re.compile("<reply>[ \t\n\r]*<data[^<]*>(.*?)</data>", re.MULTILINE | re.DOTALL)
|
||||||
|
|
||||||
|
|
||||||
class ClosingFileHandler(logging.StreamHandler):
|
class ClosingFileHandler(logging.StreamHandler):
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
super(ClosingFileHandler, self).__init__()
|
super(ClosingFileHandler, self).__init__()
|
||||||
|
|
@ -59,6 +60,7 @@ class ClosingFileHandler(logging.StreamHandler):
|
||||||
self.release()
|
self.release()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
class TestData:
|
class TestData:
|
||||||
def __init__(self, data_folder):
|
def __init__(self, data_folder):
|
||||||
self.data_folder = 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.
|
# Left-strip the data so we do not get a newline before our data.
|
||||||
return m.group(1).lstrip()
|
return m.group(1).lstrip()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
td = TestData("./data")
|
td = TestData("./data")
|
||||||
data = td.get_test_data(1451)
|
data = td.get_test_data(1451)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue