More unit tests for removing stroke properties (for stroke-width=0 or stroke=none)
This commit is contained in:
parent
f4b328ea4b
commit
d9866c99e9
7 changed files with 91 additions and 40 deletions
|
|
@ -1,10 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<defs>
|
|
||||||
|
|
||||||
</defs>
|
|
||||||
<g/>
|
|
||||||
<g></g>
|
|
||||||
<metadata />
|
|
||||||
<g>Foo</g>
|
|
||||||
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 117 B |
|
|
@ -1,5 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<defs>
|
|
||||||
|
|
||||||
</defs>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 69 B |
|
|
@ -1,9 +0,0 @@
|
||||||
<foo xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
||||||
<bar id="johansen" />
|
|
||||||
<baz xlink:href="#johansen"/>
|
|
||||||
<bar id="scarlett">
|
|
||||||
<fudge id="f1" fill="url(#scarlett)"/>
|
|
||||||
</bar>
|
|
||||||
|
|
||||||
<fudge id="f2" stroke="url(#scarlett)"/>
|
|
||||||
</foo>
|
|
||||||
101
testscour.py
101
testscour.py
|
|
@ -228,48 +228,117 @@ class KeepReferencedFonts(unittest.TestCase):
|
||||||
|
|
||||||
class ConvertStyleToAttrs(unittest.TestCase):
|
class ConvertStyleToAttrs(unittest.TestCase):
|
||||||
def runTest(self):
|
def runTest(self):
|
||||||
doc = scour.scourXmlFile('unittests/stroke-linejoin.svg')
|
doc = scour.scourXmlFile('unittests/stroke-transparent.svg')
|
||||||
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('style'), '',
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('style'), '',
|
||||||
"style attribute not emptied" )
|
"style attribute not emptied" )
|
||||||
|
|
||||||
class RemoveStrokeWhenStrokeTransparent(unittest.TestCase):
|
class RemoveStrokeWhenStrokeTransparent(unittest.TestCase):
|
||||||
def runTest(self):
|
def runTest(self):
|
||||||
doc = scour.scourXmlFile('unittests/stroke-linejoin.svg')
|
doc = scour.scourXmlFile('unittests/stroke-transparent.svg')
|
||||||
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke'), '',
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke'), '',
|
||||||
"stroke attribute not emptied" )
|
"stroke attribute not emptied when stroke opacity zero" )
|
||||||
|
|
||||||
class RemoveStrokeWidthWhenStrokeTransparent(unittest.TestCase):
|
class RemoveStrokeWidthWhenStrokeTransparent(unittest.TestCase):
|
||||||
def runTest(self):
|
def runTest(self):
|
||||||
doc = scour.scourXmlFile('unittests/stroke-linejoin.svg')
|
doc = scour.scourXmlFile('unittests/stroke-transparent.svg')
|
||||||
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-width'), '',
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-width'), '',
|
||||||
"stroke-width attribute not emptied" )
|
"stroke-width attribute not emptied when stroke opacity zero" )
|
||||||
|
|
||||||
class RemoveStrokeLinecapWhenStrokeTransparent(unittest.TestCase):
|
class RemoveStrokeLinecapWhenStrokeTransparent(unittest.TestCase):
|
||||||
def runTest(self):
|
def runTest(self):
|
||||||
doc = scour.scourXmlFile('unittests/stroke-linejoin.svg')
|
doc = scour.scourXmlFile('unittests/stroke-transparent.svg')
|
||||||
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-linecap'), '',
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-linecap'), '',
|
||||||
"stroke-linecap attribute not emptied" )
|
"stroke-linecap attribute not emptied when stroke opacity zero" )
|
||||||
|
|
||||||
class RemoveStrokeLinejoinWhenStrokeTransparent(unittest.TestCase):
|
class RemoveStrokeLinejoinWhenStrokeTransparent(unittest.TestCase):
|
||||||
def runTest(self):
|
def runTest(self):
|
||||||
doc = scour.scourXmlFile('unittests/stroke-linejoin.svg')
|
doc = scour.scourXmlFile('unittests/stroke-transparent.svg')
|
||||||
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-linejoin'), '',
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-linejoin'), '',
|
||||||
"stroke-linejoin attribute not emptied" )
|
"stroke-linejoin attribute not emptied when stroke opacity zero" )
|
||||||
|
|
||||||
class RemoveStrokeDasharrayWhenStrokeTransparent(unittest.TestCase):
|
class RemoveStrokeDasharrayWhenStrokeTransparent(unittest.TestCase):
|
||||||
def runTest(self):
|
def runTest(self):
|
||||||
doc = scour.scourXmlFile('unittests/stroke-linejoin.svg')
|
doc = scour.scourXmlFile('unittests/stroke-transparent.svg')
|
||||||
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-dasharray'), '',
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-dasharray'), '',
|
||||||
"stroke-dasharray attribute not emptied" )
|
"stroke-dasharray attribute not emptied when stroke opacity zero" )
|
||||||
|
|
||||||
class RemoveStrokeDashoffsetWhenStrokeTransparent(unittest.TestCase):
|
class RemoveStrokeDashoffsetWhenStrokeTransparent(unittest.TestCase):
|
||||||
def runTest(self):
|
def runTest(self):
|
||||||
doc = scour.scourXmlFile('unittests/stroke-linejoin.svg')
|
doc = scour.scourXmlFile('unittests/stroke-transparent.svg')
|
||||||
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-dashoffset'), '',
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-dashoffset'), '',
|
||||||
"stroke-dashoffset attribute not emptied" )
|
"stroke-dashoffset attribute not emptied when stroke opacity zero" )
|
||||||
|
|
||||||
# TODO : add in duplicate tests for when the stroke-width is 0
|
class RemoveStrokeWhenStrokeWidthZero(unittest.TestCase):
|
||||||
# TODO : add in duplicate tests for when the stroke is none
|
def runTest(self):
|
||||||
|
doc = scour.scourXmlFile('unittests/stroke-nowidth.svg')
|
||||||
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke'), '',
|
||||||
|
"stroke attribute not emptied when width zero" )
|
||||||
|
|
||||||
|
class RemoveStrokeOpacityWhenStrokeWidthZero(unittest.TestCase):
|
||||||
|
def runTest(self):
|
||||||
|
doc = scour.scourXmlFile('unittests/stroke-nowidth.svg')
|
||||||
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-opacity'), '',
|
||||||
|
"stroke-opacity attribute not emptied when width zero" )
|
||||||
|
|
||||||
|
class RemoveStrokeLinecapWhenStrokeWidthZero(unittest.TestCase):
|
||||||
|
def runTest(self):
|
||||||
|
doc = scour.scourXmlFile('unittests/stroke-nowidth.svg')
|
||||||
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-linecap'), '',
|
||||||
|
"stroke-linecap attribute not emptied when width zero" )
|
||||||
|
|
||||||
|
class RemoveStrokeLinejoinWhenStrokeWidthZero(unittest.TestCase):
|
||||||
|
def runTest(self):
|
||||||
|
doc = scour.scourXmlFile('unittests/stroke-nowidth.svg')
|
||||||
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-linejoin'), '',
|
||||||
|
"stroke-linejoin attribute not emptied when width zero" )
|
||||||
|
|
||||||
|
class RemoveStrokeDasharrayWhenStrokeWidthZero(unittest.TestCase):
|
||||||
|
def runTest(self):
|
||||||
|
doc = scour.scourXmlFile('unittests/stroke-nowidth.svg')
|
||||||
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-dasharray'), '',
|
||||||
|
"stroke-dasharray attribute not emptied when width zero" )
|
||||||
|
|
||||||
|
class RemoveStrokeDashoffsetWhenStrokeWidthZero(unittest.TestCase):
|
||||||
|
def runTest(self):
|
||||||
|
doc = scour.scourXmlFile('unittests/stroke-nowidth.svg')
|
||||||
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-dashoffset'), '',
|
||||||
|
"stroke-dashoffset attribute not emptied when width zero" )
|
||||||
|
|
||||||
|
class RemoveStrokeWhenStrokeNone(unittest.TestCase):
|
||||||
|
def runTest(self):
|
||||||
|
doc = scour.scourXmlFile('unittests/stroke-none.svg')
|
||||||
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-width'), '',
|
||||||
|
"stroke-width attribute not emptied when no stroke" )
|
||||||
|
|
||||||
|
class RemoveStrokeOpacityWhenStrokeNone(unittest.TestCase):
|
||||||
|
def runTest(self):
|
||||||
|
doc = scour.scourXmlFile('unittests/stroke-none.svg')
|
||||||
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-opacity'), '',
|
||||||
|
"stroke-opacity attribute not emptied when no stroke" )
|
||||||
|
|
||||||
|
class RemoveStrokeLinecapWhenStrokeNone(unittest.TestCase):
|
||||||
|
def runTest(self):
|
||||||
|
doc = scour.scourXmlFile('unittests/stroke-none.svg')
|
||||||
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-linecap'), '',
|
||||||
|
"stroke-linecap attribute not emptied when no stroke" )
|
||||||
|
|
||||||
|
class RemoveStrokeLinejoinWhenStrokeNone(unittest.TestCase):
|
||||||
|
def runTest(self):
|
||||||
|
doc = scour.scourXmlFile('unittests/stroke-none.svg')
|
||||||
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-linejoin'), '',
|
||||||
|
"stroke-linejoin attribute not emptied when no stroke" )
|
||||||
|
|
||||||
|
class RemoveStrokeDasharrayWhenStrokeNone(unittest.TestCase):
|
||||||
|
def runTest(self):
|
||||||
|
doc = scour.scourXmlFile('unittests/stroke-none.svg')
|
||||||
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-dasharray'), '',
|
||||||
|
"stroke-dasharray attribute not emptied when no stroke" )
|
||||||
|
|
||||||
|
class RemoveStrokeDashoffsetWhenStrokeNone(unittest.TestCase):
|
||||||
|
def runTest(self):
|
||||||
|
doc = scour.scourXmlFile('unittests/stroke-none.svg')
|
||||||
|
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-dashoffset'), '',
|
||||||
|
"stroke-dashoffset attribute not emptied when no stroke" )
|
||||||
|
|
||||||
#class RemoveUnreferencedFonts(unittest.TestCase):
|
#class RemoveUnreferencedFonts(unittest.TestCase):
|
||||||
# def runTest(self):
|
# def runTest(self):
|
||||||
|
|
@ -277,6 +346,6 @@ class RemoveStrokeDashoffsetWhenStrokeTransparent(unittest.TestCase):
|
||||||
# fonts = doc.documentElement.getElementsByTagNameNS('http://www.w3.org/2000/svg','font')
|
# fonts = doc.documentElement.getElementsByTagNameNS('http://www.w3.org/2000/svg','font')
|
||||||
# self.assertEquals(len(fonts), 0,
|
# self.assertEquals(len(fonts), 0,
|
||||||
# "Font was not removed from <defs>" )
|
# "Font was not removed from <defs>" )
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
3
unittests/stroke-none.svg
Normal file
3
unittests/stroke-none.svg
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
<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" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 323 B |
3
unittests/stroke-nowidth.svg
Normal file
3
unittests/stroke-nowidth.svg
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path id="p" fill="black" style="stroke: rgb(0, 0, 0); stroke-width: 0; 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" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 329 B |
|
Before Width: | Height: | Size: 331 B After Width: | Height: | Size: 331 B |
Loading…
Add table
Add a link
Reference in a new issue