diff --git a/rocketpy/environment/environment.py b/rocketpy/environment/environment.py index e6db229a0..da1e58f89 100644 --- a/rocketpy/environment/environment.py +++ b/rocketpy/environment/environment.py @@ -2571,7 +2571,7 @@ def set_earth_geometry(self, datum): } try: return ellipsoid[datum] - except KeyError as e: + except KeyError as e: # pragma: no cover available_datums = ', '.join(ellipsoid.keys()) raise AttributeError( f"The reference system '{datum}' is not recognized. Please use one of " diff --git a/rocketpy/rocket/aero_surface/nose_cone.py b/rocketpy/rocket/aero_surface/nose_cone.py index c1f8d59a9..bb05c8dfe 100644 --- a/rocketpy/rocket/aero_surface/nose_cone.py +++ b/rocketpy/rocket/aero_surface/nose_cone.py @@ -317,7 +317,7 @@ def bluffness(self, value): raise ValueError( "Parameter 'bluffness' must be None or 0 when using a nose cone kind 'powerseries'." ) - if value is not None and not (0 <= value <= 1): # pragma: no cover + if value is not None and not 0 <= value <= 1: # pragma: no cover raise ValueError( f"Bluffness ratio of {value} is out of range. " "It must be between 0 and 1." diff --git a/rocketpy/tools.py b/rocketpy/tools.py index e0cd35393..b873500d7 100644 --- a/rocketpy/tools.py +++ b/rocketpy/tools.py @@ -976,9 +976,8 @@ def wrapper(*args, **kwargs): for i in range(max_attempts): try: return func(*args, **kwargs) - except ( - Exception - ) as e: # pragma: no cover # pylint: disable=broad-except + # pylint: disable=broad-except + except Exception as e: # pragma: no cover if i == max_attempts - 1: raise e from None delay = min(delay * 2, max_delay) diff --git a/tests/unit/test_aero_surfaces.py b/tests/unit/test_aero_surfaces.py index 146dc593e..a59820b5f 100644 --- a/tests/unit/test_aero_surfaces.py +++ b/tests/unit/test_aero_surfaces.py @@ -76,7 +76,9 @@ def test_powerseries_nosecones_setters(power, invalid_power, new_power): @patch("matplotlib.pyplot.show") -def test_elliptical_fins_draw(mock_show, elliptical_fin_set): +def test_elliptical_fins_draw( + mock_show, elliptical_fin_set +): # pylint: disable=unused-argument assert elliptical_fin_set.plots.draw(filename=None) is None @@ -85,7 +87,9 @@ def test_nose_cone_info(calisto_nose_cone): @patch("matplotlib.pyplot.show") -def test_nose_cone_draw(mock_show, calisto_nose_cone): +def test_nose_cone_draw( + mock_show, calisto_nose_cone +): # pylint: disable=unused-argument assert calisto_nose_cone.draw(filename=None) is None diff --git a/tests/unit/test_tank.py b/tests/unit/test_tank.py index b077cd2a3..747552d00 100644 --- a/tests/unit/test_tank.py +++ b/tests/unit/test_tank.py @@ -361,5 +361,5 @@ def expected_gas_inertia(t): @patch("matplotlib.pyplot.show") -def test_tank_geometry_plots_info(mock_show): +def test_tank_geometry_plots_info(mock_show): # pylint: disable=unused-argument assert TankGeometry({(0, 5): 1}).plots.all() is None diff --git a/tests/unit/test_units.py b/tests/unit/test_units.py index e3a80c457..76cb7ed89 100644 --- a/tests/unit/test_units.py +++ b/tests/unit/test_units.py @@ -1,34 +1,32 @@ import pytest -from rocketpy.units import ( - conversion_factor, - convert_temperature, - convert_units, -) +from rocketpy.units import conversion_factor, convert_temperature, convert_units class TestConvertTemperature: + """Tests for the convert_temperature function.""" + def test_convert_temperature_same_unit(self): assert convert_temperature(300, "K", "K") == 300 assert convert_temperature(27, "degC", "degC") == 27 assert convert_temperature(80, "degF", "degF") == 80 - def test_convert_temperature_K_to_degC(self): + def test_convert_temperature_kelvin_to_celsius(self): assert convert_temperature(300, "K", "degC") == pytest.approx(26.85, rel=1e-2) - def test_convert_temperature_K_to_degF(self): + def test_convert_temperature_kelvin_to_fahrenheit(self): assert convert_temperature(300, "K", "degF") == pytest.approx(80.33, rel=1e-2) - def test_convert_temperature_degC_to_K(self): + def test_convert_temperature_celsius_to_kelvin(self): assert convert_temperature(27, "degC", "K") == pytest.approx(300.15, rel=1e-2) - def test_convert_temperature_degC_to_degF(self): + def test_convert_temperature_celsius_to_fahrenheit(self): assert convert_temperature(27, "degC", "degF") == pytest.approx(80.6, rel=1e-2) - def test_convert_temperature_degF_to_K(self): + def test_convert_temperature_fahrenheit_to_kelvin(self): assert convert_temperature(80, "degF", "K") == pytest.approx(299.817, rel=1e-2) - def test_convert_temperature_degF_to_degC(self): + def test_convert_temperature_fahrenheit_to_celsius(self): assert convert_temperature(80, "degF", "degC") == pytest.approx(26.67, rel=1e-2) def test_convert_temperature_invalid_conversion(self): @@ -39,6 +37,8 @@ def test_convert_temperature_invalid_conversion(self): class TestConversionFactor: + """Tests for the conversion_factor function.""" + def test_conversion_factor_same_unit(self): assert conversion_factor("m", "m") == 1 assert conversion_factor("ft", "ft") == 1 @@ -64,15 +64,17 @@ def test_conversion_factor_invalid_conversion(self): class TestConvertUnits: + """Tests for the convert_units function.""" + def test_convert_units_same_unit(self): assert convert_units(300, "K", "K") == 300 assert convert_units(27, "degC", "degC") == 27 assert convert_units(80, "degF", "degF") == 80 - def test_convert_units_K_to_degC(self): + def test_convert_units_kelvin_to_celsius(self): assert convert_units(300, "K", "degC") == pytest.approx(26.85, rel=1e-2) - def test_convert_units_K_to_degF(self): + def test_convert_units_kelvin_to_fahrenheit(self): assert convert_units(300, "K", "degF") == pytest.approx(80.33, rel=1e-2) def test_convert_units_kilogram_to_pound(self):