summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLukáš Ondráček <lukas.ondracek@nic.cz>2024-10-21 19:48:46 +0200
committerLukáš Ondráček <lukas.ondracek@nic.cz>2024-10-21 19:49:14 +0200
commit308b61863d52a78292c78e9c637483e2d193e9fb (patch)
tree54e1847aacb14c6ef3d0c06502fbe9df52da2214 /tests
parentpytests: change log level from debug to notice (diff)
parentMerge !1621: python: Ruff linter and formatter (diff)
downloadknot-resolver-308b61863d52a78292c78e9c637483e2d193e9fb.tar.xz
knot-resolver-308b61863d52a78292c78e9c637483e2d193e9fb.zip
Merge remote-tracking branch 'master' into rrl-wip
Diffstat (limited to 'tests')
-rw-r--r--tests/manager/datamodel/templates/test_types_render.py4
-rw-r--r--tests/manager/datamodel/test_forward_schema.py1
-rw-r--r--tests/manager/datamodel/types/test_custom_types.py8
-rw-r--r--tests/manager/test_knot_resolver_manager.py1
-rw-r--r--tests/pytests/kresd.py20
-rw-r--r--tests/pytests/proxy.py8
-rw-r--r--tests/pytests/pylintrc32
-rw-r--r--tests/pytests/utils.py3
8 files changed, 20 insertions, 57 deletions
diff --git a/tests/manager/datamodel/templates/test_types_render.py b/tests/manager/datamodel/templates/test_types_render.py
index c67d72b2..22e425f9 100644
--- a/tests/manager/datamodel/templates/test_types_render.py
+++ b/tests/manager/datamodel/templates/test_types_render.py
@@ -47,8 +47,8 @@ def test_escaped_str_multiline(val: Any, exp: str):
('""', r"\"\""),
("''", r"\'\'"),
# fmt: off
- ('\"\"', r'\"\"'),
- ("\'\'", r'\'\''),
+ ('""', r"\"\""),
+ ("''", r"\'\'"),
# fmt: on
],
)
diff --git a/tests/manager/datamodel/test_forward_schema.py b/tests/manager/datamodel/test_forward_schema.py
index 58ad4667..3d57f93e 100644
--- a/tests/manager/datamodel/test_forward_schema.py
+++ b/tests/manager/datamodel/test_forward_schema.py
@@ -36,7 +36,6 @@ def test_forward_valid(port: int, auth: bool):
[(5353, True, False), (53, True, True)],
)
def test_forward_invalid(port: int, auth: bool, tls: bool):
-
if not tls:
with raises(DataValidationError):
ForwardSchema(
diff --git a/tests/manager/datamodel/types/test_custom_types.py b/tests/manager/datamodel/types/test_custom_types.py
index e381e918..5614fd0a 100644
--- a/tests/manager/datamodel/types/test_custom_types.py
+++ b/tests/manager/datamodel/types/test_custom_types.py
@@ -130,10 +130,10 @@ def test_pin_sha256_invalid(val: str):
("\a\b\f\n\r\t\v\\", r"\a\b\f\n\r\t\v\\"),
# fmt: off
("''", r"\'\'"),
- ('""', r'\"\"'),
- ("\'\'", r"\'\'"),
- ('\"\"', r'\"\"'),
- ('\\"\\"', r'\\\"\\\"'),
+ ('""', r"\"\""),
+ ("''", r"\'\'"),
+ ('""', r"\"\""),
+ ('\\"\\"', r"\\\"\\\""),
("\\'\\'", r"\\\'\\\'"),
# fmt: on
],
diff --git a/tests/manager/test_knot_resolver_manager.py b/tests/manager/test_knot_resolver_manager.py
index 108b3b55..05d0e61d 100644
--- a/tests/manager/test_knot_resolver_manager.py
+++ b/tests/manager/test_knot_resolver_manager.py
@@ -4,7 +4,6 @@ from knot_resolver import __version__
def test_version():
-
with open("pyproject.toml", "r") as f:
pyproject = toml.load(f)
diff --git a/tests/pytests/kresd.py b/tests/pytests/kresd.py
index 21d96455..6373e63a 100644
--- a/tests/pytests/kresd.py
+++ b/tests/pytests/kresd.py
@@ -48,7 +48,7 @@ Forward = namedtuple('Forward', ['proto', 'ip', 'port', 'hostname', 'ca_file'])
class Kresd(ContextDecorator):
- def __init__(
+ def __init__( # noqa: PLR0913
self, workdir, port=None, tls_port=None, ip=None, ip6=None, certname=None,
verbose=True, hints=None, forward=None, policy_test_pass=False, rr=False,
valgrind=False):
@@ -179,7 +179,7 @@ class Kresd(ContextDecorator):
port = self.tls_port if tls else self.port
if family == socket.AF_INET:
return self.ip, port
- elif family == socket.AF_INET6:
+ if family == socket.AF_INET6:
return self.ip6, port, 0, 0
raise RuntimeError("Unsupported socket family: {}".format(family))
@@ -237,13 +237,12 @@ class Kresd(ContextDecorator):
for line in log:
if past_startup:
partial_log += line
- else: # find real start of test log (after initial alive-pings)
- if not past_startup_msgid:
- if re.match(KRESD_LOG_STARTUP_MSGID, line) is not None:
- past_startup_msgid = True
- else:
- if re.match(KRESD_LOG_IO_CLOSE, line) is not None:
- past_startup = True
+ # find real start of test log (after initial alive-pings)
+ elif not past_startup_msgid:
+ if re.match(KRESD_LOG_STARTUP_MSGID, line) is not None:
+ past_startup_msgid = True
+ elif re.match(KRESD_LOG_IO_CLOSE, line) is not None:
+ past_startup = True
return partial_log
@@ -263,8 +262,7 @@ def is_port_free(port, ip=None, ip6=None):
except OSError as exc:
if exc.errno == 98: # address already in use
return False
- else:
- raise
+ raise
return True
diff --git a/tests/pytests/proxy.py b/tests/pytests/proxy.py
index b8a53cd8..57bb6e96 100644
--- a/tests/pytests/proxy.py
+++ b/tests/pytests/proxy.py
@@ -82,7 +82,7 @@ class Proxy(ContextDecorator):
class TLSProxy(Proxy):
EXECUTABLE = 'tlsproxy'
- def __init__(
+ def __init__( # noqa: PLR0913
self,
local_ip: str = '127.0.0.1',
local_port: Optional[int] = None,
@@ -130,9 +130,9 @@ def kresd_tls_client(
kresd_fwd_target_kwargs: Optional[Dict[Any, Any]] = None
) -> Kresd:
"""kresd_tls_client --(tls)--> tlsproxy --(tcp)--> kresd_fwd_target"""
- ALLOWED_IPS = {'127.0.0.1', '::1'}
- assert proxy.local_ip in ALLOWED_IPS, "only localhost IPs supported for proxy"
- assert proxy.upstream_ip in ALLOWED_IPS, "only localhost IPs are supported for proxy"
+ allowed_ips = {'127.0.0.1', '::1'}
+ assert proxy.local_ip in allowed_ips, "only localhost IPs supported for proxy"
+ assert proxy.upstream_ip in allowed_ips, "only localhost IPs are supported for proxy"
if kresd_tls_client_kwargs is None:
kresd_tls_client_kwargs = {}
diff --git a/tests/pytests/pylintrc b/tests/pytests/pylintrc
deleted file mode 100644
index 5e2b50b5..00000000
--- a/tests/pytests/pylintrc
+++ /dev/null
@@ -1,32 +0,0 @@
-# SPDX-License-Identifier: GPL-3.0-or-later
-[MESSAGES CONTROL]
-
-disable=
- missing-docstring,
- too-few-public-methods,
- too-many-arguments,
- too-many-instance-attributes,
- fixme,
- unused-import, # checked by flake8
- line-too-long, # checked by flake8
- invalid-name,
- broad-except,
- global-statement,
- no-else-return,
- redefined-outer-name, # commonly used with pytest fixtures
- consider-using-with,
- consider-using-f-string,
-
-
-[SIMILARITIES]
-min-similarity-lines=6
-ignore-comments=yes
-ignore-docstrings=yes
-ignore-imports=no
-
-[DESIGN]
-max-parents=10
-max-locals=20
-
-[TYPECHECK]
-ignored-modules=ssl
diff --git a/tests/pytests/utils.py b/tests/pytests/utils.py
index 8af71aad..1290c86d 100644
--- a/tests/pytests/utils.py
+++ b/tests/pytests/utils.py
@@ -40,8 +40,7 @@ def receive_parse_answer(sock):
if data_answer is None:
raise BrokenPipeError("kresd closed connection")
- msg_answer = dns.message.from_wire(data_answer, one_rr_per_rrset=True)
- return msg_answer
+ return dns.message.from_wire(data_answer, one_rr_per_rrset=True)
def prepare_wire(