示例#1
0
 def test_ref_unit(self):
     cup = CustomUnitPolicy(
         [ScaleUnitConversion(Unit('km'), Unit('m'), 1000)])
     assert cup.ref_unit(Unit('km')) == Unit('m')
     assert cup.ref_unit(Unit('m')) == Unit('m')
     with raises(ValueError):
         cup.ref_unit(Unit('furlong'))  # unit doesn't exist
示例#2
0
 def test_duplicate_overwrite(self):
     cup = CustomUnitPolicy([
         ScaleUnitConversion(Unit('km'), Unit('m'), 1000),
         ScaleUnitConversion(Unit('km'), Unit('mm'), 1000000)
     ],
                            duplicates='overwrite')
     assert cup.ref_unit(Unit('km')) == Unit('mm')