Fix a bug compress_partitioned with some specific 'max_linelen' (trailing \n)
This commit is contained in:
parent
fe7fcf6b26
commit
5f98a44d80
|
@ -491,6 +491,7 @@ def compress_partitioned(css,
|
|||
assert max_rules_per_file > 0
|
||||
|
||||
css, preserved_tokens = _compress(css, max_linelen=max_linelen)
|
||||
css = css.strip()
|
||||
|
||||
bufs = []
|
||||
buf = []
|
||||
|
|
|
@ -108,3 +108,31 @@ class Tests(unittest.TestCase):
|
|||
output = compress_partitioned(input, max_rules_per_file=2)
|
||||
assert output == ['a,a1,a2{color:red}', 'b,b2,b3{color:red}',
|
||||
'c,c3,c4,c5{color:red}', 'd{color:red}']
|
||||
|
||||
def test_partition_8(self):
|
||||
input = '''
|
||||
@media{
|
||||
a {p: 1}
|
||||
b {p: 2}
|
||||
x {p: 2}
|
||||
}
|
||||
@media{
|
||||
c {p: 1}
|
||||
d {p: 2}
|
||||
y {p: 2}
|
||||
}
|
||||
@media{
|
||||
e {p: 1}
|
||||
f {p: 2}
|
||||
z {p: 2}
|
||||
}
|
||||
z {p: 2}
|
||||
'''
|
||||
|
||||
# carefully pick 'max_linelen' to have a trailing '\n' after
|
||||
# '_compress' call
|
||||
output = compress_partitioned(input, max_rules_per_file=2, max_linelen=6)
|
||||
assert output == ['@media{a{p:1}\nb{p:2}x{p:2}\n}',
|
||||
'@media{c{p:1}\nd{p:2}y{p:2}\n}',
|
||||
'@media{e{p:1}\nf{p:2}z{p:2}\n}',
|
||||
'z{p:2}']
|
||||
|
|
Loading…
Reference in New Issue