* keep classes by default, fixes #33 * full test coverage
This commit is contained in:
parent
cc18022e33
commit
cfe687b05b
|
@ -1,4 +1,4 @@
|
|||
from __future__ import absolute_import, unicode_literals
|
||||
from .premailer import Premailer, transform
|
||||
|
||||
__version__ = '2.11.0'
|
||||
__version__ = '3.0.0'
|
||||
|
|
|
@ -121,7 +121,7 @@ class Premailer(object):
|
|||
exclude_pseudoclasses=True,
|
||||
keep_style_tags=False,
|
||||
include_star_selectors=False,
|
||||
remove_classes=True,
|
||||
remove_classes=False,
|
||||
capitalize_float_margin=False,
|
||||
strip_important=True,
|
||||
external_styles=None,
|
||||
|
|
|
@ -170,6 +170,37 @@ class Tests(unittest.TestCase):
|
|||
|
||||
compare_html(expect_html, result_html)
|
||||
|
||||
def test_remove_classes(self):
|
||||
"""test the simplest case"""
|
||||
|
||||
html = """<html>
|
||||
<head>
|
||||
<title>Title</title>
|
||||
<style type="text/css">
|
||||
.stuff {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p class="stuff"><strong>Yes!</strong></p>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
expect_html = """<html>
|
||||
<head>
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
<p style="color:red"><strong>Yes!</strong></p>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
p = Premailer(html, remove_classes=True)
|
||||
result_html = p.transform()
|
||||
|
||||
compare_html(expect_html, result_html)
|
||||
|
||||
def test_basic_html_shortcut_function(self):
|
||||
"""test the plain transform function"""
|
||||
html = """<html>
|
||||
|
@ -1088,7 +1119,7 @@ b
|
|||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div style="color:red"></div>
|
||||
<div class="example" style="color:red"></div>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
|
@ -1118,7 +1149,7 @@ b
|
|||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div style="color:green"></div>
|
||||
<div class="example" style="color:green"></div>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
|
@ -1148,7 +1179,7 @@ b
|
|||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div style="color:green"></div>
|
||||
<div class="example" style="color:green"></div>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
|
@ -1178,7 +1209,7 @@ b
|
|||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div id="identified" style="color:green"></div>
|
||||
<div class="example" id="identified" style="color:green"></div>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
|
@ -1195,7 +1226,7 @@ b
|
|||
color: blue !important;
|
||||
font-size: 12px;
|
||||
}
|
||||
#identified {
|
||||
#id {
|
||||
color: green;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
@ -1205,17 +1236,17 @@ b
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="example makeblue" id="identified"></div>
|
||||
<div class="example makeblue" id="id"></div>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
expect_html = """<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div id="identified" style="font-size:22px; color:blue"></div>
|
||||
</body>
|
||||
</html>"""
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div class="example makeblue" id="id" style="font-size:22px; color:blue"></div>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
p = Premailer(html)
|
||||
result_html = p.transform()
|
||||
|
@ -1285,7 +1316,7 @@ ration:none">Yes!</strong></p>
|
|||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1 style="color:green">Hi!</h1>
|
||||
<h1 class="foo" style="color:green">Hi!</h1>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
|
@ -2395,7 +2426,7 @@ sheet" type="text/css">
|
|||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div style="color:green; font-size:10px"></div>
|
||||
<div class="color example" style="color:green; font-size:10px"></div>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
|
@ -2453,22 +2484,22 @@ sheet" type="text/css">
|
|||
</head>
|
||||
<body>
|
||||
<p><img src="/images/left.jpg" style="float: left"> text
|
||||
<img src="/images/right.png" class="floatright"> text
|
||||
<img src="/r.png" class="floatright"> text
|
||||
<img src="/images/nofloat.gif"> text
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
expect_html = """<html>
|
||||
<head>
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
<p><img src="/images/left.jpg" style="float: left" align="left"> text
|
||||
<img src="/images/right.png" style="float:right" align="right"> text
|
||||
<img src="/images/nofloat.gif"> text
|
||||
</p>
|
||||
</body>
|
||||
</html>"""
|
||||
<head>
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
<p><img src="/images/left.jpg" style="float: left" align="left"> text
|
||||
<img src="/r.png" class="floatright" style="float:right" align="right"> text
|
||||
<img src="/images/nofloat.gif"> text
|
||||
</p>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
p = Premailer(html, align_floating_images=True)
|
||||
result_html = p.transform()
|
||||
|
@ -2498,7 +2529,8 @@ sheet" type="text/css">
|
|||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div style="color:green"><span></span></div>
|
||||
<div class="color" style="color:green"><span class="nocolor"></span>
|
||||
</div>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
|
|
Loading…
Reference in New Issue