diff --git a/fulltests/emptyElems.svg b/fulltests/emptyElems.svg deleted file mode 100644 index cc5b707..0000000 --- a/fulltests/emptyElems.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - Foo - - \ No newline at end of file diff --git a/fulltests/emptyElems2.svg b/fulltests/emptyElems2.svg deleted file mode 100644 index cdf254c..0000000 --- a/fulltests/emptyElems2.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/fulltests/foo.xml b/fulltests/foo.xml deleted file mode 100644 index 736d84c..0000000 --- a/fulltests/foo.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/testscour.py b/testscour.py index bcb8e95..92d62b3 100755 --- a/testscour.py +++ b/testscour.py @@ -228,48 +228,117 @@ class KeepReferencedFonts(unittest.TestCase): class ConvertStyleToAttrs(unittest.TestCase): 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'), '', "style attribute not emptied" ) class RemoveStrokeWhenStrokeTransparent(unittest.TestCase): 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'), '', - "stroke attribute not emptied" ) + "stroke attribute not emptied when stroke opacity zero" ) class RemoveStrokeWidthWhenStrokeTransparent(unittest.TestCase): 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'), '', - "stroke-width attribute not emptied" ) + "stroke-width attribute not emptied when stroke opacity zero" ) class RemoveStrokeLinecapWhenStrokeTransparent(unittest.TestCase): 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'), '', - "stroke-linecap attribute not emptied" ) + "stroke-linecap attribute not emptied when stroke opacity zero" ) class RemoveStrokeLinejoinWhenStrokeTransparent(unittest.TestCase): 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'), '', - "stroke-linejoin attribute not emptied" ) + "stroke-linejoin attribute not emptied when stroke opacity zero" ) class RemoveStrokeDasharrayWhenStrokeTransparent(unittest.TestCase): 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'), '', - "stroke-dasharray attribute not emptied" ) + "stroke-dasharray attribute not emptied when stroke opacity zero" ) class RemoveStrokeDashoffsetWhenStrokeTransparent(unittest.TestCase): 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'), '', - "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 -# TODO : add in duplicate tests for when the stroke is none +class RemoveStrokeWhenStrokeWidthZero(unittest.TestCase): + 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): # def runTest(self): @@ -277,6 +346,6 @@ class RemoveStrokeDashoffsetWhenStrokeTransparent(unittest.TestCase): # fonts = doc.documentElement.getElementsByTagNameNS('http://www.w3.org/2000/svg','font') # self.assertEquals(len(fonts), 0, # "Font was not removed from " ) - + if __name__ == '__main__': unittest.main() diff --git a/unittests/stroke-none.svg b/unittests/stroke-none.svg new file mode 100644 index 0000000..17b6ac4 --- /dev/null +++ b/unittests/stroke-none.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/unittests/stroke-nowidth.svg b/unittests/stroke-nowidth.svg new file mode 100644 index 0000000..5815fab --- /dev/null +++ b/unittests/stroke-nowidth.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/unittests/stroke-linejoin.svg b/unittests/stroke-transparent.svg similarity index 100% rename from unittests/stroke-linejoin.svg rename to unittests/stroke-transparent.svg