Add unittests for 1cde426009 and 641d2db08a392e4a7df20c700e1accb9cd8d1341

This commit is contained in:
Eduard Braun 2016-09-11 00:16:17 +02:00
parent 0b5bb5184c
commit 10e687b887
2 changed files with 31 additions and 1 deletions

View file

@ -495,12 +495,30 @@ class RemoveStrokeWhenStrokeNone(unittest.TestCase):
self.assertEqual(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke'), '', self.assertEqual(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke'), '',
'stroke attribute not emptied when no stroke' ) 'stroke attribute not emptied when no stroke' )
class KeepStrokeWhenInheritedFromParent(unittest.TestCase):
def runTest(self):
doc = scour.scourXmlFile('unittests/stroke-none.svg')
self.assertEqual(doc.getElementById('p1').getAttribute('stroke'), 'none',
'stroke attribute removed despite a different value being inherited from a parent' )
class KeepStrokeWhenInheritedByChild(unittest.TestCase):
def runTest(self):
doc = scour.scourXmlFile('unittests/stroke-none.svg')
self.assertEqual(doc.getElementById('g2').getAttribute('stroke'), 'none',
'stroke attribute removed despite it being inherited by a child' )
class RemoveStrokeWidthWhenStrokeNone(unittest.TestCase): class RemoveStrokeWidthWhenStrokeNone(unittest.TestCase):
def runTest(self): def runTest(self):
doc = scour.scourXmlFile('unittests/stroke-none.svg') doc = scour.scourXmlFile('unittests/stroke-none.svg')
self.assertEqual(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-width'), '', self.assertEqual(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-width'), '',
'stroke-width attribute not emptied when no stroke' ) 'stroke-width attribute not emptied when no stroke' )
class KeepStrokeWidthWhenInheritedByChild(unittest.TestCase):
def runTest(self):
doc = scour.scourXmlFile('unittests/stroke-none.svg')
self.assertEqual(doc.getElementById('g3').getAttribute('stroke-width'), '1px',
'stroke-width attribute removed despite it being inherited by a child' )
class RemoveStrokeOpacityWhenStrokeNone(unittest.TestCase): class RemoveStrokeOpacityWhenStrokeNone(unittest.TestCase):
def runTest(self): def runTest(self):
doc = scour.scourXmlFile('unittests/stroke-none.svg') doc = scour.scourXmlFile('unittests/stroke-none.svg')

View file

@ -1,4 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg"> <svg xmlns="http://www.w3.org/2000/svg">
<path id="p" fill="black" style="stroke: none; stroke-width: 1px; stroke-linecap: butt; stroke-dasharray: none; stroke-dashoffset: 2; stroke-linejoin: miter; stroke-opacity: 1;" 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: none; stroke-width: 1px; stroke-linecap: butt; stroke-dasharray: none; stroke-dashoffset: 2; stroke-linejoin: miter; stroke-opacity: 1;" d="M 7.7592046,36.982095 C 7.8831049,40.873696 7.8339808,45.305308 7.8339808,49.436888 Z" />
<g id="g1" style="stroke:#000">
<path id="p0" d="M 7.7592046,36.982095 C 7.8831049,40.873696 7.8339808,45.305308 7.8339808,49.436888 Z" />
<path id="p1" style="stroke:none" d="M 7.7592046,36.982095 C 7.8831049,40.873696 7.8339808,45.305308 7.8339808,49.436888 Z" />
<g id="g2" style="stroke:none">
<path id="p2" d="M 7.7592046,36.982095 C 7.8831049,40.873696 7.8339808,45.305308 7.8339808,49.436888 Z" />
</g>
</g>
<g id="g3" style="stroke:none;stroke-width:1px">
<path id="p3" style="stroke:#000" d="M 7.7592046,36.982095 C 7.8831049,40.873696 7.8339808,45.305308 7.8339808,49.436888 Z" />
</g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 379 B

After

Width:  |  Height:  |  Size: 995 B

Before After
Before After