A few more unit tests for removing stroke properties
This commit is contained in:
parent
d09903fe39
commit
64ee621aa6
3 changed files with 22 additions and 5 deletions
10
scour.py
10
scour.py
|
|
@ -455,8 +455,9 @@ def repairStyle(node):
|
|||
for uselessStyle in ['fill', 'fill-opacity', 'fill-rule', 'stroke', 'stroke-linejoin',
|
||||
'stroke-opacity', 'stroke-miterlimit', 'stroke-linecap', 'stroke-dasharray',
|
||||
'stroke-dashoffset', 'stroke-opacity'] :
|
||||
del styleMap[uselessStyle]
|
||||
num += 1
|
||||
if styleMap.has_key(uselessStyle):
|
||||
del styleMap[uselessStyle]
|
||||
num += 1
|
||||
|
||||
# if stroke:none, then remove all stroke-related properties (stroke-width, etc)
|
||||
# TODO: should also detect if the computed value of this element is fill="none"
|
||||
|
|
@ -490,8 +491,9 @@ def repairStyle(node):
|
|||
num += 1
|
||||
elif fillOpacity == 0.0 :
|
||||
for uselessFillStyle in [ 'fill', 'fill-rule' ] :
|
||||
del styleMap[uselessFillStyle]
|
||||
num += 1
|
||||
if styleMap.has_key(uselessFillStyle):
|
||||
del styleMap[uselessFillStyle]
|
||||
num += 1
|
||||
|
||||
# stroke-opacity: 1 or 0
|
||||
if styleMap.has_key('stroke-opacity') :
|
||||
|
|
|
|||
15
testscour.py
15
testscour.py
|
|
@ -256,6 +256,21 @@ class RemoveStrokeLinejoinWhenStrokeTransparent(unittest.TestCase):
|
|||
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-linejoin'), '',
|
||||
"stroke-linejoin attribute not emptied" )
|
||||
|
||||
class RemoveStrokeDasharrayWhenStrokeTransparent(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/stroke-linejoin.svg')
|
||||
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-dasharray'), '',
|
||||
"stroke-dasharray attribute not emptied" )
|
||||
|
||||
class RemoveStrokeDashoffsetWhenStrokeTransparent(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/stroke-linejoin.svg')
|
||||
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-dashoffset'), '',
|
||||
"stroke-dashoffset attribute not emptied" )
|
||||
|
||||
# TODO : add in duplicate tests for when the stroke-width is 0
|
||||
# TODO : add in duplicate tests for when the stroke is none
|
||||
|
||||
#class RemoveUnreferencedFonts(unittest.TestCase):
|
||||
# def runTest(self):
|
||||
# doc = scour.scourXmlFile('unittests/unreferenced-font.svg')
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<path id="p" fill="black" style="stroke: rgb(0, 0, 0); stroke-width: 1px; stroke-linecap: butt; stroke-linejoin: miter; stroke-opacity: 0;" d="M 7.7592046,36.982095 C 7.8831049,40.873696 7.8339808,45.305308 7.8339808,49.436888 Z" />
|
||||
<path id="p" fill="black" style="stroke: rgb(0, 0, 0); stroke-width: 1px; stroke-linecap: butt; stroke-dasharray: none; stroke-dashoffset: 2; stroke-linejoin: miter; stroke-opacity: 0;" d="M 7.7592046,36.982095 C 7.8831049,40.873696 7.8339808,45.305308 7.8339808,49.436888 Z" />
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 285 B After Width: | Height: | Size: 331 B |
Loading…
Add table
Add a link
Reference in a new issue