def test_from_string(self): properties = Properties.from_string('color: red; font-weight: bold') self.assertEqual(properties, { 'color': 'red', 'font-weight': 'bold', }) properties = Properties.from_string('padding: 0 10px') self.assertEqual(properties, { 'padding-top': '0', 'padding-right': '10px', 'padding-bottom': '0', 'padding-left': '10px', })
def test_from_string(self): properties = Properties.from_string('color: red; font-weight: bold') self.assertEqual(properties, { 'color': 'red', 'font-weight': 'bold', }) properties = Properties.from_string('padding: 0 10px') self.assertEqual( properties, { 'padding-top': '0', 'padding-right': '10px', 'padding-bottom': '0', 'padding-left': '10px', })
def test_does_not_override_inlined_styles(self): tree = html.document_fromstring(""" <html> <head> <style type="text/css"> h1 { color: red; display: block; } </style> </head> <body> <h1 style="color: blue; font-weight: bold">Hello, world.</h1> </body> </html> """) inline(tree) heading, = tree.cssselect('h1') properties = Properties.from_string(heading.attrib['style']) self.assertEqual(properties, { 'color': 'blue', 'display': 'block', 'font-weight': 'bold', })
def test_does_not_override_inlined_styles(self): tree = html.document_fromstring(""" <html> <head> <style type="text/css"> h1 { color: red; display: block; } </style> </head> <body> <h1 style="color: blue; font-weight: bold">Hello, world.</h1> </body> </html> """) inline(tree) heading, = tree.cssselect('h1') properties = Properties.from_string(heading.attrib['style']) self.assertEqual(properties, { 'color': 'blue', 'display': 'block', 'font-weight': 'bold', })
def test_from_string_cleans_whitespace(self): properties = Properties.from_string( 'color : red;\nfont-weight: bold ;') self.assertEqual(properties, { 'color': 'red', 'font-weight': 'bold', })
def test_from_string_cleans_whitespace(self): properties = Properties.from_string('color : red;\nfont-weight: bold ;') self.assertEqual(properties, { 'color': 'red', 'font-weight': 'bold', })
def test_from_string(self): properties = Properties.from_string('color: red; font-weight: bold') self.assertEqual(properties, { 'color': 'red', 'font-weight': 'bold', })
def test_from_string(self): properties = Properties.from_string('color: red; font-weight: bold') self.assertEqual(properties, { 'color': 'red', 'font-weight': 'bold', })