示例#1
0
 def test_known_units(self, unit):
     _, parsed_unit, _ = parse_size('100%s@100dpi' % unit)
     assert parsed_unit == unit
示例#2
0
 def test_parse_named_densities(self, name, value):
     _, _, density = parse_size('100px@%sdpi' % name)
     assert density == value
示例#3
0
 def test_unknown_named_density_fails(self):
     try:
         parse_size('100dp@foodpi')
         pytest.fail('Expected ValueError to be raised')
     except ValueError as e:
         assert 'Invalid density: "foo"' in str(e)
示例#4
0
 def test_size_number_parsing(self, value):
     size, _, _ = parse_size('%sdp' % value)
     assert size == value
示例#5
0
 def test_use_default_density_when_none_given(self):
     _, _, density = parse_size('100sp')
     assert density == DENSITY_DEFAULT
示例#6
0
 def test_size_not_number(self):
     try:
         parse_size('1.1.1dp')
         pytest.fail('Expected ValueError to be raised')
     except ValueError as e:
         assert '1.1.1 is not a number' in str(e)
示例#7
0
 def test_size_not_number(self):
     try:
         parse_size('1.1.1dp')
         pytest.fail('Expected ValueError to be raised')
     except ValueError as e:
         assert '1.1.1 is not a number' in str(e)
示例#8
0
 def test_unknown_unit(self):
     try:
         parse_size('100xx')
         pytest.fail('Expected ValueError to be raised')
     except ValueError as e:
         assert 'Unknown unit: "xx"' in str(e)
示例#9
0
 def test_px_input_requires_density(self):
     try:
         parse_size('100px')
         pytest.fail('Expected ValueError to be raised')
     except ValueError as e:
         assert 'px conversions require density' in str(e)
示例#10
0
 def test_unknown_named_density_fails(self):
     try:
         parse_size('100dp@foodpi')
         pytest.fail('Expected ValueError to be raised')
     except ValueError as e:
         assert 'Invalid density: "foo"' in str(e)
示例#11
0
 def test_known_units(self, unit):
     _, parsed_unit, _ = parse_size('100%s@100dpi' % unit)
     assert parsed_unit == unit
示例#12
0
 def test_parse_named_densities(self, name, value):
     _, _, density = parse_size('100px@%sdpi' % name)
     assert density == value
示例#13
0
 def test_use_default_density_when_none_given(self):
     _, _, density = parse_size('100sp')
     assert density == DENSITY_DEFAULT
示例#14
0
 def test_size_number_parsing(self, value):
     size, _, _ = parse_size('%sdp' % value)
     assert size == value
示例#15
0
 def test_unknown_unit(self):
     try:
         parse_size('100xx')
         pytest.fail('Expected ValueError to be raised')
     except ValueError as e:
         assert 'Unknown unit: "xx"' in str(e)
示例#16
0
 def test_bad_input_string(self):
     try:
         parse_size('asdf')
         pytest.fail('Expected ValueError to be raised')
     except ValueError as e:
         assert 'Could not parse' in str(e)
示例#17
0
 def test_px_input_requires_density(self):
     try:
         parse_size('100px')
         pytest.fail('Expected ValueError to be raised')
     except ValueError as e:
         assert 'px conversions require density' in str(e)
示例#18
0
 def test_bad_input_string(self):
     try:
         parse_size('asdf')
         pytest.fail('Expected ValueError to be raised')
     except ValueError as e:
         assert 'Could not parse' in str(e)