Skip to content

Commit 29a7aaa

Browse files
committed
Fix pylint warnings in GenericMotor tests
1 parent 8e03cbd commit 29a7aaa

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

.pylintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[MAIN]
2+
# pylint: disable=unrecognized-option
23

34
# Analyse import fallback blocks. This can be used to support both Python 2 and
45
# 3 compatible code, which means that the block might have code that exists

tests/unit/motors/test_genericmotor.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def test_load_from_rse_file(generic_motor):
216216
assert thrust_curve[-1][1] == 0.0 # Last thrust point
217217

218218

219-
def test_load_from_thrustcurve_api(monkeypatch, generic_motor):
219+
def test_load_from_thrustcurve_api(monkeypatch, _generic_motor): # pylint: disable=too-many-statements
220220
"""
221221
Tests the GenericMotor.load_from_thrustcurve_api method with mocked ThrustCurve API responses.
222222
Parameters
@@ -243,7 +243,7 @@ def raise_for_status(self):
243243
return None
244244

245245
# Provide mocked responses for the two endpoints: search.json and download.json
246-
def mock_get(url, params=None):
246+
def mock_get(url, _params=None):
247247
if "search.json" in url:
248248
# Return a mock search result with a motorId and designation
249249
return MockResponse(
@@ -266,7 +266,7 @@ def mock_get(url, params=None):
266266
else:
267267
raise RuntimeError(f"Unexpected URL called in test mock: {url}")
268268

269-
monkeypatch.setattr(requests, "get", mock_get)
269+
monkeypatch.setattr(requests, "get", mock_get) # noqa: F821
270270

271271
# Expected parameters from the original test
272272
burn_time = (0, 3.9)
@@ -283,7 +283,7 @@ def mock_get(url, params=None):
283283

284284
# Call the method using the class (works if it's a staticmethod); using type(generic_motor)
285285
# ensures test works if the method is invoked on a GenericMotor instance in the project
286-
motor = type(generic_motor).load_from_thrustcurve_api("M1670")
286+
motor = type(_generic_motor).load_from_thrustcurve_api("M1670") # noqa: F821
287287

288288
# Assertions (same as original)
289289
assert motor.burn_time == burn_time
@@ -305,17 +305,17 @@ def mock_get(url, params=None):
305305
)
306306

307307
# 1. No motor found
308-
def mock_get_no_motor(url, params=None):
308+
def mock_get_no_motor(url, _params=None):
309309
if "search.json" in url:
310310
return MockResponse({"results": []})
311311
return MockResponse({"results": []})
312312

313-
monkeypatch.setattr(requests, "get", mock_get_no_motor)
313+
monkeypatch.setattr(requests, "get", mock_get_no_motor) # noqa: F821
314314
with pytest.raises(ValueError, match="No motor found"):
315-
type(generic_motor).load_from_thrustcurve_api("NonexistentMotor")
315+
type(_generic_motor).load_from_thrustcurve_api("NonexistentMotor")
316316

317317
# 2. No .eng file found
318-
def mock_get_no_eng(url, params=None):
318+
def mock_get_no_eng(url, _params=None):
319319
if "search.json" in url:
320320
return MockResponse(
321321
{
@@ -332,12 +332,12 @@ def mock_get_no_eng(url, params=None):
332332
return MockResponse({"results": []})
333333
return MockResponse({})
334334

335-
monkeypatch.setattr(requests, "get", mock_get_no_eng)
335+
monkeypatch.setattr(requests, "get", mock_get_no_eng) # noqa :F821
336336
with pytest.raises(ValueError, match="No .eng file found"):
337-
type(generic_motor).load_from_thrustcurve_api("FakeMotor")
337+
type(_generic_motor).load_from_thrustcurve_api("FakeMotor") #noqa:F821
338338

339339
# 3. Empty .eng data
340-
def mock_get_empty_data(url, params=None):
340+
def mock_get_empty_data(url, _params=None):
341341
if "search.json" in url:
342342
return MockResponse(
343343
{
@@ -354,6 +354,6 @@ def mock_get_empty_data(url, params=None):
354354
return MockResponse({"results": [{"data": ""}]})
355355
return MockResponse({})
356356

357-
monkeypatch.setattr(requests, "get", mock_get_empty_data)
357+
monkeypatch.setattr(requests, "get", mock_get_empty_data) #noqa: F821
358358
with pytest.raises(ValueError, match="Downloaded .eng data"):
359-
type(generic_motor).load_from_thrustcurve_api("FakeMotor")
359+
type(_generic_motor).load_from_thrustcurve_api("FakeMotor") #noqa: F821

0 commit comments

Comments
 (0)