def test_format_units_v_step_si(self): # Tests (input, step, result, 'Error String') tests = [ (1, 100, 1, 'format_units(1, 100, \'si\') != 1'), (1.0, 100, 1.0, 'format_units(1.0, 100, \'si\') != 1.0'), (0.001, 100, 0.001, 'format_units(0.001, 100, \'si\') != 0.001') ] for (t, s, r, e) in tests: self.assertEqual(glyph.format_units(t, s, 'si'), (r, ''), e)
def test_format_units_val_None_defaults(self): # Tests (input, result, 'Error String') tests = [ (1, 1, 'format_units(1, None) != 1'), (1.0, 1.0, 'format_units(1.0, None) != 1.0'), (0.001, 0.001, 'format_units(0.001, None) != 0.001') ] for (t, r, e) in tests: self.assertEqual(glyph.format_units(t, None), (r, ''), e)
def test_format_units_defaults(self): # Tests (input, result, prefix, 'Error String') tests = [ (1, 1, '', 'format_units(1) != 1'), (1.0, 1.0, '', 'format_units(1.0) != 1.0'), (0.001, 0.001, '', 'format_units(0.001) != 0.001'), (1000, 1.0, 'K', 'format_units(1000) != 1.0 K'), (1000000, 1.0, 'M', 'format_units(1000000) != 1.0 M'), ] for (t, r, p, e) in tests: self.assertEqual(glyph.format_units(t), (r, p), e)
def test_format_units_v_None_si(self): # Tests (input, result, prefix, 'Error String') tests = [ (1, 1, '', 'format_units(1, None, \'si\') != 1'), (1.0, 1.0, '', 'format_units(1.0, None, \'si\') != 1.0'), (0.001, 0.001, '', 'format_units(0.001, None, \'si\') != 0.001'), (1000, 1.0, 'K', 'format_units(1000, None, \'si\') != 1.0 K'), (1000000, 1.0, 'M', 'format_units(1000000, None, \'si\') != 1.0 M'), ] for (t, r, p, e) in tests: self.assertEqual(glyph.format_units(t, None, 'si'), (r, p), e)
def test_format_units_v_step_si_units(self): # Tests (input, step, result, prefix, 'Error String') tests = [ (1, 100, 1, 'b', 'format_units(1, 100, \'si\', \'b\') != 1'), (1.0, 100, 1.0, 'b', 'format_units(1.0, 100, \'si\', \'b\') != 1.0'), (0.001, 100, 0.001, 'b', 'format_units(0.001, 100, \'si\', \'b\') != 0.001'), (1000, 100, 1000.0, 'b', 'format_units(1000, 100, \'si\', \'b\') != 1000.0'), (1000000, 100, 1000000.0, 'b', 'format_units(1000000, 100, \'si\', \'b\') != 1000000.0'), ] for (t, s, r, p, e) in tests: self.assertEqual(glyph.format_units(t, s, 'si', 'b'), (r, p), e)