Esempio n. 1
0
 def test_adddocumentunit_non_float(self):
     """Strings that are invalid floats should pass through unchanged."""
     doc = uu_svg('pt')
     inputs = (
         '',
         'ABCD',
         '.',
         '   ',
     )
     for value in inputs:
         self.assertEqual(doc.add_unit(value), '')
Esempio n. 2
0
 def test_adddocumentunit_common(self):
     """Test common add_unit results"""
     # For valid float inputs, the output should be the input with the user unit appended.
     doc = uu_svg('pt')
     cases = (
         # Input, expected output
         (100, '100pt'),
         ('100', '100pt'),
         ('+100', '100pt'),
         ('-100', '-100pt'),
         ('100.0', '100pt'),
         ('100.0e0', '100pt'),
         ('10.0e1', '100pt'),
         ('10.0e+1', '100pt'),
         ('1000.0e-1', '100pt'),
         ('.1e+3', '100pt'),
         ('+.1e+3', '100pt'),
         ('   100', '100pt'),
         ('100   ', '100pt'),
         ('  100   ', '100pt'),
     )
     for input_value, expected in cases:
         self.assertEqual(doc.add_unit(input_value), expected)
Esempio n. 3
0
 def assertFromUserUnit(self, user_unit, value, unit, expected):  # pylint: disable=invalid-name
     """Check converting from a user unity for the test_value"""
     self.assertAlmostEqual(uu_svg(user_unit).uutounit(value, unit), expected)
Esempio n. 4
0
 def test_uutounit_unknown_unit(self):
     """Demonstrate that passing an unknown unit string to uutounit()"""
     self.assertEqual(uu_svg('in').uutounit(1, 'px'), 96.0)
Esempio n. 5
0
 def assertToUserUnit(self, user_unit, test_value, expected):  # pylint: disable=invalid-name
     """Checks a user unit and a test_value against the expected result"""
     doc = uu_svg(user_unit)
     self.assertEqual(doc.unit, user_unit, msg=svg)
     self.assertAlmostEqual(doc.unittouu(test_value), expected)