Skip to content

Commit e071a8b

Browse files
authored
test: run pylint against test files (#592)
This should help us write better tests and catch invalid tests.
1 parent 28cb4b8 commit e071a8b

File tree

24 files changed

+36
-40
lines changed

24 files changed

+36
-40
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ venv:
77

88
lint: venv
99
venv/bin/pylint hcloud
10+
venv/bin/pylint tests --disable=missing-function-docstring,use-dict-literal,protected-access,redefined-outer-name,unnecessary-dunder-call
1011
venv/bin/mypy hcloud
1112

1213
test: venv

tests/unit/actions/test_domain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
],
2121
)
2222
def test_eq(value):
23-
assert value == value
23+
assert value.__eq__(value)
2424

2525

2626
class TestAction:

tests/unit/certificates/test_domain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
],
2222
)
2323
def test_eq(value):
24-
assert value == value
24+
assert value.__eq__(value)
2525

2626

2727
class TestCertificate:

tests/unit/core/test_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_get_non_exists_model_attribute_complete_model(
4747
client=client, data={"id": 1, "name": "name", "description": "description"}
4848
)
4949
with pytest.raises(AttributeError):
50-
bound_model.content
50+
_ = bound_model.content
5151
client.get_by_id.assert_not_called()
5252

5353
def test_get_exists_model_attribute_incomplete_model(
@@ -77,7 +77,7 @@ def test_get_non_exists_model_attribute_incomplete_model(
7777
):
7878
bound_model = bound_model_class(client=client, data={"id": 1}, complete=False)
7979
with pytest.raises(AttributeError):
80-
bound_model.content
80+
_ = bound_model.content
8181
client.get_by_id.assert_not_called()
8282
assert bound_model.complete is False
8383

@@ -137,7 +137,7 @@ def get_actions_list(self, status, page=None, per_page=None):
137137
def test_iter_pages_no_meta(self, client_class_constructor):
138138
json_content = {"candies": [1, 2]}
139139

140-
def json_content_function(p):
140+
def json_content_function(_):
141141
return json_content
142142

143143
candies_client = client_class_constructor(json_content_function)
@@ -152,7 +152,7 @@ def test_iter_pages_no_next_page(self, client_class_constructor):
152152
"meta": {"pagination": {"page": 1, "per_page": 11, "next_page": None}},
153153
}
154154

155-
def json_content_function(p):
155+
def json_content_function(_):
156156
return json_content
157157

158158
candies_client = client_class_constructor(json_content_function)
@@ -218,7 +218,7 @@ def json_content_function(p):
218218
def test_get_first_by_result_exists(self, client_class_constructor):
219219
json_content = {"candies": [1]}
220220

221-
def json_content_function(p):
221+
def json_content_function(_):
222222
return json_content
223223

224224
candies_client = client_class_constructor(json_content_function)
@@ -230,7 +230,7 @@ def json_content_function(p):
230230
def test_get_first_by_result_does_not_exist(self, client_class_constructor):
231231
json_content = {"candies": []}
232232

233-
def json_content_function(p):
233+
def json_content_function(_):
234234
return json_content
235235

236236
candies_client = client_class_constructor(json_content_function)

tests/unit/datacenters/test_domain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
],
1414
)
1515
def test_eq(value):
16-
assert value == value
16+
assert value.__eq__(value)

tests/unit/deprecation/test_domain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
],
1313
)
1414
def test_eq(value):
15-
assert value == value
15+
assert value.__eq__(value)

tests/unit/exp/test_zone.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def test_is_txt_record_quoted(value: str, expected: bool):
1717
assert is_txt_record_quoted(value) == expected
1818

1919

20-
manyA = "a" * 255
21-
someB = "b" * 10
20+
MANY_A = "a" * 255
21+
SOME_B = "b" * 10
2222

2323

2424
@pytest.mark.parametrize(
@@ -30,7 +30,7 @@ def test_is_txt_record_quoted(value: str, expected: bool):
3030
("hello\nworld", '"hello\nworld"'),
3131
('hello "world"', '"hello \\"world\\""'),
3232
('hello "world', '"hello \\"world"'),
33-
(manyA + someB, f'"{manyA}" "{someB}"'),
33+
(MANY_A + SOME_B, f'"{MANY_A}" "{SOME_B}"'),
3434
],
3535
)
3636
def test_format_txt_record(value: str, expected: str):

tests/unit/firewalls/test_domain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
],
2626
)
2727
def test_eq(value):
28-
assert value == value
28+
assert value.__eq__(value)
2929

3030

3131
class TestFirewall:

tests/unit/floating_ips/test_client.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,10 @@ def test_create_with_server(
228228
assert bound_floating_ip.description == "Web Frontend"
229229
assert action.id == 13
230230

231-
@pytest.mark.parametrize(
232-
"server", [Server(id=1), BoundServer(mock.MagicMock(), dict(id=1))]
233-
)
234231
def test_create_with_name(
235232
self,
236233
request_mock: mock.MagicMock,
237234
floating_ips_client: FloatingIPsClient,
238-
server,
239235
floating_ip_create_response,
240236
):
241237
request_mock.return_value = floating_ip_create_response

tests/unit/floating_ips/test_domain.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
],
1616
)
1717
def test_eq(value):
18-
assert value == value
18+
assert value.__eq__(value)
1919

2020

2121
class TestFloatingIP:
2222
def test_created_is_datetime(self):
23-
floatingIP = FloatingIP(id=1, created="2016-01-30T23:50+00:00")
24-
assert floatingIP.created == datetime.datetime(
23+
floating_ip = FloatingIP(id=1, created="2016-01-30T23:50+00:00")
24+
assert floating_ip.created == datetime.datetime(
2525
2016, 1, 30, 23, 50, tzinfo=timezone.utc
2626
)

0 commit comments

Comments
 (0)