Exemplo n.º 1
0
 def test_px_to_em_invalid_input(self):
     # Expect the value to pass through unchanged.
     invalid_inputs = ['1 2', '5 6 5 6', 'cat', '11px', ' 234.8', 'n2_4p', '25deg', '16kHz', ]
     for invalid in invalid_inputs:
         expected = invalid
         actual = settings.px_to_em(pixels=invalid)
         self.assertEqual(actual, expected, msg=invalid)
Exemplo n.º 2
0
 def test_px_to_em_int_input(self):
     base = 16
     for pixels in range(-1000, 1001):
         expected = round(pixels / base, 4)
         expected = str(expected) + 'em'
         actual = settings.px_to_em(pixels=pixels)
         self.assertEqual(actual, str(expected), msg=pixels)
Exemplo n.º 3
0
 def test_px_to_em_change_base(self):
     base = 16
     for pixels in range(-1000, 1001):
         expected = round(pixels / base, 4)
         expected = str(expected) + 'em'
         actual = settings.px_to_em(pixels=pixels)
         self.assertEqual(actual, expected, msg=str(actual) + ' vs ' + str(expected))
Exemplo n.º 4
0
 def test_px_to_em_float_input(self):
     base = 16
     # Thank you: http://stackoverflow.com/questions/477486/python-decimal-range-step-value#answer-477506
     for pixels in range(-11, 11, 1):
         pixels /= 10.0
         expected = round(float(pixels) / float(base), 4)
         expected = str(expected) + 'em'
         actual = settings.px_to_em(pixels=pixels)
         self.assertEqual(actual, str(expected), msg=str(pixels) + ': ' + str(actual) + ' vs ' + str(expected))