Skip to content

Commit 0e5fc9c

Browse files
anandkaranubccardoe
authored andcommitted
Stop ignoring assignment in tests
Drop `assignment` from the test override's `disable_error_code`. Two issues surfaced, both fixed at the source. In `tests/unit/utils.py`, `FakeAPI._request` widened a fixed-length tuple with `+=`; build each tuple shape directly and append to `self.calls`. In `tests/unit/osc/v1/fakes.py`, `osc_lib`'s `FakeClientManager.auth_ref` is inferred as `None`, so direct assignment is rejected; use `setattr` with a TODO pointing at the upstream fix. Change-Id: Ideda1f4c71e70b86e8f04d1d2d8af40d538429ce Signed-off-by: Karan Anand <anandkarancompsci@gmail.com>
1 parent fae5aac commit 0e5fc9c

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

ironicclient/tests/unit/osc/v1/fakes.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,11 @@ class TestBaremetal(utils.TestCommand):
353353
def setUp(self) -> None:
354354
super(TestBaremetal, self).setUp()
355355

356-
self.app.client_manager.auth_ref = mock.Mock(auth_token="TOKEN")
356+
# TODO(anandkaranubc): drop setattr once osc_lib annotates
357+
# FakeClientManager.auth_ref as ``object | None`` (currently inferred
358+
# as ``None``, so direct assignment trips ``[assignment]``).
359+
setattr(self.app.client_manager, 'auth_ref',
360+
mock.Mock(auth_token="TOKEN"))
357361
self.app.client_manager.baremetal = mock.Mock()
358362

359363

ironicclient/tests/unit/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ def _request(
6868
# url should always just be a path here, e.g. /v1/nodes
6969
url = self.path_prefix + url
7070

71-
call = (method, url, headers or {}, body)
7271
if params:
73-
call += (params,)
74-
self.calls.append(call)
72+
self.calls.append((method, url, headers or {}, body, params))
73+
else:
74+
self.calls.append((method, url, headers or {}, body))
7575
return self.responses[url][method]
7676

7777
def raw_request(

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ disallow_untyped_defs = false
201201
disallow_subclassing_any = false
202202
disable_error_code = [
203203
"arg-type",
204-
"assignment",
205204
"attr-defined",
206205
"call-arg",
207206
"dict-item",

0 commit comments

Comments
 (0)