From 80c90b25e4947ddfa3a952b08081d811db219641 Mon Sep 17 00:00:00 2001 From: jo Date: Thu, 13 Nov 2025 20:55:47 +0100 Subject: [PATCH] test: run pylint against test files --- Makefile | 1 + tests/unit/actions/test_domain.py | 2 +- tests/unit/certificates/test_domain.py | 2 +- tests/unit/core/test_client.py | 12 ++++++------ tests/unit/datacenters/test_domain.py | 2 +- tests/unit/deprecation/test_domain.py | 2 +- tests/unit/exp/test_zone.py | 6 +++--- tests/unit/firewalls/test_domain.py | 2 +- tests/unit/floating_ips/test_client.py | 4 ---- tests/unit/floating_ips/test_domain.py | 6 +++--- tests/unit/images/test_domain.py | 2 +- tests/unit/isos/test_domain.py | 2 +- tests/unit/load_balancer_types/test_domain.py | 2 +- tests/unit/load_balancers/test_domain.py | 2 +- tests/unit/locations/test_domain.py | 2 +- tests/unit/networks/test_domain.py | 2 +- tests/unit/placement_groups/test_client.py | 4 +--- tests/unit/placement_groups/test_domain.py | 2 +- tests/unit/primary_ips/test_domain.py | 6 +++--- tests/unit/server_types/test_domain.py | 2 +- tests/unit/servers/test_client.py | 1 + tests/unit/servers/test_domain.py | 2 +- tests/unit/ssh_keys/test_domain.py | 6 +++--- tests/unit/volumes/test_domain.py | 2 +- 24 files changed, 36 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index 9a063b01..cd3ea5e9 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ venv: lint: venv venv/bin/pylint hcloud + venv/bin/pylint tests --disable=missing-function-docstring,use-dict-literal,protected-access,redefined-outer-name,unnecessary-dunder-call venv/bin/mypy hcloud test: venv diff --git a/tests/unit/actions/test_domain.py b/tests/unit/actions/test_domain.py index c5efcde5..395af182 100644 --- a/tests/unit/actions/test_domain.py +++ b/tests/unit/actions/test_domain.py @@ -20,7 +20,7 @@ ], ) def test_eq(value): - assert value == value + assert value.__eq__(value) class TestAction: diff --git a/tests/unit/certificates/test_domain.py b/tests/unit/certificates/test_domain.py index d65a61ee..3c3b2517 100644 --- a/tests/unit/certificates/test_domain.py +++ b/tests/unit/certificates/test_domain.py @@ -21,7 +21,7 @@ ], ) def test_eq(value): - assert value == value + assert value.__eq__(value) class TestCertificate: diff --git a/tests/unit/core/test_client.py b/tests/unit/core/test_client.py index d2ff4250..6e9561fd 100644 --- a/tests/unit/core/test_client.py +++ b/tests/unit/core/test_client.py @@ -47,7 +47,7 @@ def test_get_non_exists_model_attribute_complete_model( client=client, data={"id": 1, "name": "name", "description": "description"} ) with pytest.raises(AttributeError): - bound_model.content + _ = bound_model.content client.get_by_id.assert_not_called() def test_get_exists_model_attribute_incomplete_model( @@ -77,7 +77,7 @@ def test_get_non_exists_model_attribute_incomplete_model( ): bound_model = bound_model_class(client=client, data={"id": 1}, complete=False) with pytest.raises(AttributeError): - bound_model.content + _ = bound_model.content client.get_by_id.assert_not_called() assert bound_model.complete is False @@ -137,7 +137,7 @@ def get_actions_list(self, status, page=None, per_page=None): def test_iter_pages_no_meta(self, client_class_constructor): json_content = {"candies": [1, 2]} - def json_content_function(p): + def json_content_function(_): return json_content candies_client = client_class_constructor(json_content_function) @@ -152,7 +152,7 @@ def test_iter_pages_no_next_page(self, client_class_constructor): "meta": {"pagination": {"page": 1, "per_page": 11, "next_page": None}}, } - def json_content_function(p): + def json_content_function(_): return json_content candies_client = client_class_constructor(json_content_function) @@ -218,7 +218,7 @@ def json_content_function(p): def test_get_first_by_result_exists(self, client_class_constructor): json_content = {"candies": [1]} - def json_content_function(p): + def json_content_function(_): return json_content candies_client = client_class_constructor(json_content_function) @@ -230,7 +230,7 @@ def json_content_function(p): def test_get_first_by_result_does_not_exist(self, client_class_constructor): json_content = {"candies": []} - def json_content_function(p): + def json_content_function(_): return json_content candies_client = client_class_constructor(json_content_function) diff --git a/tests/unit/datacenters/test_domain.py b/tests/unit/datacenters/test_domain.py index 09ed99ed..58666bf6 100644 --- a/tests/unit/datacenters/test_domain.py +++ b/tests/unit/datacenters/test_domain.py @@ -13,4 +13,4 @@ ], ) def test_eq(value): - assert value == value + assert value.__eq__(value) diff --git a/tests/unit/deprecation/test_domain.py b/tests/unit/deprecation/test_domain.py index 35c8473f..4ab020e9 100644 --- a/tests/unit/deprecation/test_domain.py +++ b/tests/unit/deprecation/test_domain.py @@ -12,4 +12,4 @@ ], ) def test_eq(value): - assert value == value + assert value.__eq__(value) diff --git a/tests/unit/exp/test_zone.py b/tests/unit/exp/test_zone.py index b595111d..f787cd08 100644 --- a/tests/unit/exp/test_zone.py +++ b/tests/unit/exp/test_zone.py @@ -17,8 +17,8 @@ def test_is_txt_record_quoted(value: str, expected: bool): assert is_txt_record_quoted(value) == expected -manyA = "a" * 255 -someB = "b" * 10 +MANY_A = "a" * 255 +SOME_B = "b" * 10 @pytest.mark.parametrize( @@ -30,7 +30,7 @@ def test_is_txt_record_quoted(value: str, expected: bool): ("hello\nworld", '"hello\nworld"'), ('hello "world"', '"hello \\"world\\""'), ('hello "world', '"hello \\"world"'), - (manyA + someB, f'"{manyA}" "{someB}"'), + (MANY_A + SOME_B, f'"{MANY_A}" "{SOME_B}"'), ], ) def test_format_txt_record(value: str, expected: str): diff --git a/tests/unit/firewalls/test_domain.py b/tests/unit/firewalls/test_domain.py index ec303c14..7924fbb7 100644 --- a/tests/unit/firewalls/test_domain.py +++ b/tests/unit/firewalls/test_domain.py @@ -25,7 +25,7 @@ ], ) def test_eq(value): - assert value == value + assert value.__eq__(value) class TestFirewall: diff --git a/tests/unit/floating_ips/test_client.py b/tests/unit/floating_ips/test_client.py index 6bc991b9..cc271c66 100644 --- a/tests/unit/floating_ips/test_client.py +++ b/tests/unit/floating_ips/test_client.py @@ -228,14 +228,10 @@ def test_create_with_server( assert bound_floating_ip.description == "Web Frontend" assert action.id == 13 - @pytest.mark.parametrize( - "server", [Server(id=1), BoundServer(mock.MagicMock(), dict(id=1))] - ) def test_create_with_name( self, request_mock: mock.MagicMock, floating_ips_client: FloatingIPsClient, - server, floating_ip_create_response, ): request_mock.return_value = floating_ip_create_response diff --git a/tests/unit/floating_ips/test_domain.py b/tests/unit/floating_ips/test_domain.py index a16a25b4..98be19e6 100644 --- a/tests/unit/floating_ips/test_domain.py +++ b/tests/unit/floating_ips/test_domain.py @@ -15,12 +15,12 @@ ], ) def test_eq(value): - assert value == value + assert value.__eq__(value) class TestFloatingIP: def test_created_is_datetime(self): - floatingIP = FloatingIP(id=1, created="2016-01-30T23:50+00:00") - assert floatingIP.created == datetime.datetime( + floating_ip = FloatingIP(id=1, created="2016-01-30T23:50+00:00") + assert floating_ip.created == datetime.datetime( 2016, 1, 30, 23, 50, tzinfo=timezone.utc ) diff --git a/tests/unit/images/test_domain.py b/tests/unit/images/test_domain.py index d85c8a18..4ff6c133 100644 --- a/tests/unit/images/test_domain.py +++ b/tests/unit/images/test_domain.py @@ -15,7 +15,7 @@ ], ) def test_eq(value): - assert value == value + assert value.__eq__(value) class TestImage: diff --git a/tests/unit/isos/test_domain.py b/tests/unit/isos/test_domain.py index c056f3b7..f6c72a15 100644 --- a/tests/unit/isos/test_domain.py +++ b/tests/unit/isos/test_domain.py @@ -14,7 +14,7 @@ ], ) def test_eq(value): - assert value == value + assert value.__eq__(value) class TestIso: diff --git a/tests/unit/load_balancer_types/test_domain.py b/tests/unit/load_balancer_types/test_domain.py index d3b8eff7..bbd0129c 100644 --- a/tests/unit/load_balancer_types/test_domain.py +++ b/tests/unit/load_balancer_types/test_domain.py @@ -12,4 +12,4 @@ ], ) def test_eq(value): - assert value == value + assert value.__eq__(value) diff --git a/tests/unit/load_balancers/test_domain.py b/tests/unit/load_balancers/test_domain.py index 8de47d4d..47b081f2 100644 --- a/tests/unit/load_balancers/test_domain.py +++ b/tests/unit/load_balancers/test_domain.py @@ -52,7 +52,7 @@ ], ) def test_eq(value): - assert value == value + assert value.__eq__(value) class TestLoadBalancers: diff --git a/tests/unit/locations/test_domain.py b/tests/unit/locations/test_domain.py index fd5d710a..387e6264 100644 --- a/tests/unit/locations/test_domain.py +++ b/tests/unit/locations/test_domain.py @@ -12,4 +12,4 @@ ], ) def test_eq(value): - assert value == value + assert value.__eq__(value) diff --git a/tests/unit/networks/test_domain.py b/tests/unit/networks/test_domain.py index 187de5fb..dc3d3ba7 100644 --- a/tests/unit/networks/test_domain.py +++ b/tests/unit/networks/test_domain.py @@ -17,7 +17,7 @@ ], ) def test_eq(value): - assert value == value + assert value.__eq__(value) class TestNetwork: diff --git a/tests/unit/placement_groups/test_client.py b/tests/unit/placement_groups/test_client.py index 0c35d41b..fc8cada8 100644 --- a/tests/unit/placement_groups/test_client.py +++ b/tests/unit/placement_groups/test_client.py @@ -68,9 +68,7 @@ def test_get_by_id( request_mock.assert_called_with( method="GET", - url="/placement_groups/{placement_group_id}".format( - placement_group_id=placement_group_response["placement_group"]["id"] - ), + url="/placement_groups/897", ) assert placement_group._client is resource_client diff --git a/tests/unit/placement_groups/test_domain.py b/tests/unit/placement_groups/test_domain.py index f8293fcc..0d25b54f 100644 --- a/tests/unit/placement_groups/test_domain.py +++ b/tests/unit/placement_groups/test_domain.py @@ -15,7 +15,7 @@ ], ) def test_eq(value): - assert value == value + assert value.__eq__(value) class TestPlacementGroup: diff --git a/tests/unit/primary_ips/test_domain.py b/tests/unit/primary_ips/test_domain.py index 5adcf226..c1fadf0a 100644 --- a/tests/unit/primary_ips/test_domain.py +++ b/tests/unit/primary_ips/test_domain.py @@ -15,12 +15,12 @@ ], ) def test_eq(value): - assert value == value + assert value.__eq__(value) class TestPrimaryIP: def test_created_is_datetime(self): - primaryIP = PrimaryIP(id=1, created="2016-01-30T23:50+00:00") - assert primaryIP.created == datetime.datetime( + primary_ip = PrimaryIP(id=1, created="2016-01-30T23:50+00:00") + assert primary_ip.created == datetime.datetime( 2016, 1, 30, 23, 50, tzinfo=timezone.utc ) diff --git a/tests/unit/server_types/test_domain.py b/tests/unit/server_types/test_domain.py index 4d7a28c2..6d449061 100644 --- a/tests/unit/server_types/test_domain.py +++ b/tests/unit/server_types/test_domain.py @@ -12,4 +12,4 @@ ], ) def test_eq(value): - assert value == value + assert value.__eq__(value) diff --git a/tests/unit/servers/test_client.py b/tests/unit/servers/test_client.py index f3cb490e..ebf1da24 100644 --- a/tests/unit/servers/test_client.py +++ b/tests/unit/servers/test_client.py @@ -68,6 +68,7 @@ def resource_client(self, client: Client): def bound_model(self, resource_client: ServersClient): return BoundServer(resource_client, data=dict(id=14)) + # pylint: disable=too-many-statements def test_init(self, response_full_server): bound_server = BoundServer( client=mock.MagicMock(), data=response_full_server["server"] diff --git a/tests/unit/servers/test_domain.py b/tests/unit/servers/test_domain.py index 9048501f..2a80380c 100644 --- a/tests/unit/servers/test_domain.py +++ b/tests/unit/servers/test_domain.py @@ -40,7 +40,7 @@ ], ) def test_eq(value): - assert value == value + assert value.__eq__(value) class TestServer: diff --git a/tests/unit/ssh_keys/test_domain.py b/tests/unit/ssh_keys/test_domain.py index e354128e..9521f3a5 100644 --- a/tests/unit/ssh_keys/test_domain.py +++ b/tests/unit/ssh_keys/test_domain.py @@ -15,12 +15,12 @@ ], ) def test_eq(value): - assert value == value + assert value.__eq__(value) class TestSSHKey: def test_created_is_datetime(self): - sshKey = SSHKey(id=1, created="2016-01-30T23:50+00:00") - assert sshKey.created == datetime.datetime( + ssh_key = SSHKey(id=1, created="2016-01-30T23:50+00:00") + assert ssh_key.created == datetime.datetime( 2016, 1, 30, 23, 50, tzinfo=timezone.utc ) diff --git a/tests/unit/volumes/test_domain.py b/tests/unit/volumes/test_domain.py index f69329d9..50d54d43 100644 --- a/tests/unit/volumes/test_domain.py +++ b/tests/unit/volumes/test_domain.py @@ -15,7 +15,7 @@ ], ) def test_eq(value): - assert value == value + assert value.__eq__(value) class TestVolume: