Enforce kwargs in unit system initialisation (#80620)

* Enforce kwargs in unit system initialisation

* Fix tests

* Sort kwargs in unit_system
This commit is contained in:
epenet
2022-10-20 10:43:32 +02:00
committed by GitHub
parent d78c2a31a1
commit 8a1cc05e0c
3 changed files with 77 additions and 76 deletions

View File

@@ -39,85 +39,85 @@ def test_invalid_units():
with pytest.raises(ValueError):
UnitSystem(
SYSTEM_NAME,
INVALID_UNIT,
LENGTH_METERS,
SPEED_METERS_PER_SECOND,
VOLUME_LITERS,
MASS_GRAMS,
PRESSURE_PA,
LENGTH_MILLIMETERS,
temperature=INVALID_UNIT,
length=LENGTH_METERS,
wind_speed=SPEED_METERS_PER_SECOND,
volume=VOLUME_LITERS,
mass=MASS_GRAMS,
pressure=PRESSURE_PA,
accumulated_precipitation=LENGTH_MILLIMETERS,
)
with pytest.raises(ValueError):
UnitSystem(
SYSTEM_NAME,
TEMP_CELSIUS,
INVALID_UNIT,
SPEED_METERS_PER_SECOND,
VOLUME_LITERS,
MASS_GRAMS,
PRESSURE_PA,
LENGTH_MILLIMETERS,
temperature=TEMP_CELSIUS,
length=INVALID_UNIT,
wind_speed=SPEED_METERS_PER_SECOND,
volume=VOLUME_LITERS,
mass=MASS_GRAMS,
pressure=PRESSURE_PA,
accumulated_precipitation=LENGTH_MILLIMETERS,
)
with pytest.raises(ValueError):
UnitSystem(
SYSTEM_NAME,
TEMP_CELSIUS,
LENGTH_METERS,
INVALID_UNIT,
VOLUME_LITERS,
MASS_GRAMS,
PRESSURE_PA,
LENGTH_MILLIMETERS,
temperature=TEMP_CELSIUS,
length=LENGTH_METERS,
wind_speed=INVALID_UNIT,
volume=VOLUME_LITERS,
mass=MASS_GRAMS,
pressure=PRESSURE_PA,
accumulated_precipitation=LENGTH_MILLIMETERS,
)
with pytest.raises(ValueError):
UnitSystem(
SYSTEM_NAME,
TEMP_CELSIUS,
LENGTH_METERS,
SPEED_METERS_PER_SECOND,
INVALID_UNIT,
MASS_GRAMS,
PRESSURE_PA,
LENGTH_MILLIMETERS,
temperature=TEMP_CELSIUS,
length=LENGTH_METERS,
wind_speed=SPEED_METERS_PER_SECOND,
volume=INVALID_UNIT,
mass=MASS_GRAMS,
pressure=PRESSURE_PA,
accumulated_precipitation=LENGTH_MILLIMETERS,
)
with pytest.raises(ValueError):
UnitSystem(
SYSTEM_NAME,
TEMP_CELSIUS,
LENGTH_METERS,
SPEED_METERS_PER_SECOND,
VOLUME_LITERS,
INVALID_UNIT,
PRESSURE_PA,
LENGTH_MILLIMETERS,
temperature=TEMP_CELSIUS,
length=LENGTH_METERS,
wind_speed=SPEED_METERS_PER_SECOND,
volume=VOLUME_LITERS,
mass=INVALID_UNIT,
pressure=PRESSURE_PA,
accumulated_precipitation=LENGTH_MILLIMETERS,
)
with pytest.raises(ValueError):
UnitSystem(
SYSTEM_NAME,
TEMP_CELSIUS,
LENGTH_METERS,
SPEED_METERS_PER_SECOND,
VOLUME_LITERS,
MASS_GRAMS,
INVALID_UNIT,
LENGTH_MILLIMETERS,
temperature=TEMP_CELSIUS,
length=LENGTH_METERS,
wind_speed=SPEED_METERS_PER_SECOND,
volume=VOLUME_LITERS,
mass=MASS_GRAMS,
pressure=INVALID_UNIT,
accumulated_precipitation=LENGTH_MILLIMETERS,
)
with pytest.raises(ValueError):
UnitSystem(
SYSTEM_NAME,
TEMP_CELSIUS,
LENGTH_METERS,
SPEED_METERS_PER_SECOND,
VOLUME_LITERS,
MASS_GRAMS,
PRESSURE_PA,
INVALID_UNIT,
temperature=TEMP_CELSIUS,
length=LENGTH_METERS,
wind_speed=SPEED_METERS_PER_SECOND,
volume=VOLUME_LITERS,
mass=MASS_GRAMS,
pressure=PRESSURE_PA,
accumulated_precipitation=INVALID_UNIT,
)