def test_inches_less_than_cm(value): """A given length is less measured in inches than in cm.""" assume(value > 0) converted = convert_units(value, 'inches', 'cm') assert value < converted
def test_cm_less_than_mm(value): """A given length is less measured in cm than in mm.""" assume(value > 0) converted = convert_units(value, 'cm', 'mm') assert value < converted
def test_cm_greater_than_inches(value): """A given length is greater measured in cm than in inches.""" assume(value > 0) converted = convert_units(value, 'cm', 'inches') assert value > converted
def test_mm_greater_than_cm(value): """A given length is greater measured in mm than in cm.""" assume(value > 0) converted = convert_units(value, 'mm', 'cm') assert value > converted
def test_roundtrip(value, source_units, target_units): """Round-trip conversion should not change the value.""" converted = convert_units(value, source_units, target_units) round_tripped = convert_units(converted, target_units, source_units) assert almost_equal(round_tripped, value)
def test_identity(value, units): """Converting to the same unit is the identity.""" converted = convert_units(value, units, units) assert converted == value