예제 #1
0
    def test_mm_and_formatting(self, ppmm):
        # Integer and float support
        assert css_dimension_to_mm("123mm", ppmm) == 123
        assert css_dimension_to_mm("1.23mm", ppmm) == 1.23

        # With optional plus
        assert css_dimension_to_mm("+1mm", ppmm) == 1

        # With whitespace
        assert css_dimension_to_mm(" 1 mm ", ppmm) == 1
        assert css_dimension_to_mm(" + 1 mm ", ppmm) == 1
예제 #2
0
    def test_unsupported_units(self, ppmm):
        # No font-relative sizes
        with pytest.raises(ValueError):
            css_dimension_to_mm("1em", ppmm)

        # No viewport-relative sizes
        with pytest.raises(ValueError):
            css_dimension_to_mm("1vw", ppmm)
        with pytest.raises(ValueError):
            css_dimension_to_mm("1%", ppmm)
예제 #3
0
 def test_malformed(self, value, ppmm):
     with pytest.raises(ValueError):
         css_dimension_to_mm(value, ppmm)
예제 #4
0
 def test_negative(self, ppmm):
     with pytest.raises(ValueError):
         css_dimension_to_mm("-1mm", ppmm)
예제 #5
0
    def test_pixels(self, ppmm):
        assert css_dimension_to_mm("1px", ppmm) == 1.0 / ppmm
        assert css_dimension_to_mm("1", ppmm) == 1.0 / ppmm

        assert css_dimension_to_mm("2px", ppmm) == 2.0 / ppmm
        assert css_dimension_to_mm("2", ppmm) == 2.0 / ppmm
예제 #6
0
 def test_point(self, ppmm):
     assert css_dimension_to_mm("72pt", ppmm) == \
         css_dimension_to_mm("1in", ppmm)
예제 #7
0
 def test_pica(self, ppmm):
     assert css_dimension_to_mm("6pc", ppmm) == \
         css_dimension_to_mm("1in", ppmm)
예제 #8
0
 def test_inches(self, ppmm):
     assert css_dimension_to_mm("1in", ppmm) == 25.4
     assert css_dimension_to_mm("2in", ppmm) == 50.8
예제 #9
0
 def test_Q(self, ppmm):
     assert css_dimension_to_mm("1Q", ppmm) == 0.25
     assert css_dimension_to_mm("4Q", ppmm) == 1.0
예제 #10
0
 def test_cm(self, ppmm):
     assert css_dimension_to_mm("1.2cm", ppmm) == 12.0