Ejemplo n.º 1
0
    def test_keyframes_rules(self):
        input = b"""@keyframes line-scale {
    0%,
    40%,
    100% {
        transform: scaleY(0.4);
    }
    20% {
        transform: scaleY(1);
    }
}
"""
        expected = """@keyframes line-scale {
    0%,
    40%,
    100% {
        transform: scaleY(0.4);
    }
    20% {
        transform: scaleY(1);
    }
}
"""
        buffer = legacy.BytesIO(input)
        result = stylesheets.cleanup_properties(
            buffer,
            windows_newline = False,
            property_order = (
                "transform"
            )
        )
        result.seek(0)
        result = result.read()
        self.assertEqual(result, expected)
Ejemplo n.º 2
0
    def test_prefix_rules(self):
        input = b""".line-scale {
    animation: fade-in 1s ease-in-out;
}
"""
        expected = """.line-scale {
    animation: fade-in 1s ease-in-out;
    -o-animation: fade-in 1s ease-in-out;
    -ms-animation: fade-in 1s ease-in-out;
    -moz-animation: fade-in 1s ease-in-out;
    -khtml-animation: fade-in 1s ease-in-out;
    -webkit-animation: fade-in 1s ease-in-out;
}
"""
        buffer = legacy.BytesIO(input)
        result = stylesheets.cleanup_properties(
            buffer,
            windows_newline = False,
            property_order = (
                "animation",
                "-o-animation",
                "-ms-animation",
                "-moz-animation",
                "-khtml-animation",
                "-webkit-animation",
            )
        )
        result.seek(0)
        result = result.read()
        self.assertEqual(result, expected)
Ejemplo n.º 3
0
    def test_at_rules(self):
        input = b"""@charset "utf-8";"""
        expected = """@charset "utf-8";
"""
        buffer = legacy.BytesIO(input)
        result = stylesheets.cleanup_properties(
            buffer,
            windows_newline = False
        )
        result.seek(0)
        result = result.read()
        self.assertEqual(result, expected)
Ejemplo n.º 4
0
    def test_sub_rules(self):
        input = b"""@media     (max-width: 539px)    and     (min-width:   375px)   {
        slave {
max-width: 1170px;;;
  border   : 0;
        }

main,
            master {
  padding   : 0;
   -webkit-border-radius: 3px;;;
        }
}
"""
        expected = """@media (max-width: 539px) and (min-width: 375px) {
    slave {
        border: none;
        max-width: 1170px;
    }

    main,
    master {
        border-radius: 3px 3px 3px 3px;
        -o-border-radius: 3px 3px 3px 3px;
        -ms-border-radius: 3px 3px 3px 3px;
        -moz-border-radius: 3px 3px 3px 3px;
        -khtml-border-radius: 3px 3px 3px 3px;
        -webkit-border-radius: 3px 3px 3px 3px;
        padding: 0px 0px 0px 0px;
    }
}
"""
        buffer = legacy.BytesIO(input)
        result = stylesheets.cleanup_properties(
            buffer,
            windows_newline = False,
            property_order = (
                "border",
                "border-radius",
                "-o-border-radius",
                "-ms-border-radius",
                "-moz-border-radius",
                "-khtml-border-radius",
                "-webkit-border-radius",
                "max-width",
                "padding"
            )
        )
        result.seek(0)
        result = result.read()
        self.assertEqual(result, expected)
Ejemplo n.º 5
0
    def test_rules(self):
        input = b""".property>.sub  >   .sub-sub  ,
        .property2    >.sub  >   .sub-sub  {
    margin   : 80px auto;
     border: 0;


      max-width: 1170px;;;
  padding: 0px 0px 32px 0px
  border-radius: 2px;
  -webkit-border-radius: 2px;;
   }
"""
        expected = """.property > .sub > .sub-sub,
.property2 > .sub > .sub-sub {
    border: none;
    border-radius: 2px 2px 2px 2px;
    -o-border-radius: 2px 2px 2px 2px;
    -ms-border-radius: 2px 2px 2px 2px;
    -moz-border-radius: 2px 2px 2px 2px;
    -khtml-border-radius: 2px 2px 2px 2px;
    -webkit-border-radius: 2px 2px 2px 2px;
    margin: 80px auto 80px auto;
    max-width: 1170px;
    padding: 0px 0px 32px 0px;
}
"""
        buffer = legacy.BytesIO(input)
        result = stylesheets.cleanup_properties(
            buffer,
            windows_newline = False,
            property_order = (
                "border",
                "border-radius",
                "-o-border-radius",
                "-ms-border-radius",
                "-moz-border-radius",
                "-khtml-border-radius",
                "-webkit-border-radius",
                "margin",
                "max-width",
                "padding"
            )
        )
        result.seek(0)
        result = result.read()
        self.assertEqual(result, expected)