Fix Bug 405744: Keep namespace declarations when --keep-editor-data. Add tests.
This commit is contained in:
parent
4ee372f561
commit
8f50f0d509
3 changed files with 44 additions and 13 deletions
3
scra.py
3
scra.py
|
|
@ -83,6 +83,7 @@ class ScourOptions:
|
||||||
group_collapse = True
|
group_collapse = True
|
||||||
strip_ids = False
|
strip_ids = False
|
||||||
digits = 5
|
digits = 5
|
||||||
|
embed_rasters = False
|
||||||
keep_editor_data = False
|
keep_editor_data = False
|
||||||
|
|
||||||
# params are the form elements (if a checkbox is unchecked it will not be present)
|
# params are the form elements (if a checkbox is unchecked it will not be present)
|
||||||
|
|
@ -104,6 +105,6 @@ def fetch(req, indoc,**params):
|
||||||
|
|
||||||
fileitem = fs['upload']
|
fileitem = fs['upload']
|
||||||
if fileitem.filename:
|
if fileitem.filename:
|
||||||
req.write(scourString(fileitem.file.read()))
|
req.write(scourString(fileitem.file.read(), options))
|
||||||
else:
|
else:
|
||||||
req.write(scourString(indoc,options))
|
req.write(scourString(indoc,options))
|
||||||
|
|
|
||||||
30
testscour.py
30
testscour.py
|
|
@ -44,6 +44,7 @@ class ScourOptions:
|
||||||
strip_ids = False
|
strip_ids = False
|
||||||
digits = 5
|
digits = 5
|
||||||
embed_rasters = True
|
embed_rasters = True
|
||||||
|
keep_editor_data = False
|
||||||
|
|
||||||
class NoInkscapeElements(unittest.TestCase):
|
class NoInkscapeElements(unittest.TestCase):
|
||||||
def runTest(self):
|
def runTest(self):
|
||||||
|
|
@ -257,6 +258,34 @@ class NoInkscapeAttributes(unittest.TestCase):
|
||||||
findInkscapeAttr), False,
|
findInkscapeAttr), False,
|
||||||
'Found Inkscape attributes' )
|
'Found Inkscape attributes' )
|
||||||
|
|
||||||
|
class KeepInkscapeNamespaceDeclarationsWhenKeepEditorData(unittest.TestCase):
|
||||||
|
def runTest(self):
|
||||||
|
options = ScourOptions
|
||||||
|
options.keep_editor_data = True
|
||||||
|
attrs = scour.scourXmlFile('unittests/inkscape.svg', options).documentElement.attributes
|
||||||
|
FoundNamespace = False
|
||||||
|
for i in range(len(attrs)):
|
||||||
|
if attrs.item(i).nodeValue == 'http://www.inkscape.org/namespaces/inkscape':
|
||||||
|
FoundNamespace = True
|
||||||
|
break
|
||||||
|
self.assertEquals(True, FoundNamespace,
|
||||||
|
"Did not find Inkscape namespace declaration when using --keep-editor-data")
|
||||||
|
return False
|
||||||
|
|
||||||
|
class KeepSodipodiNamespaceDeclarationsWhenKeepEditorData(unittest.TestCase):
|
||||||
|
def runTest(self):
|
||||||
|
options = ScourOptions
|
||||||
|
options.keep_editor_data = True
|
||||||
|
attrs = scour.scourXmlFile('unittests/sodipodi.svg', options).documentElement.attributes
|
||||||
|
FoundNamespace = False
|
||||||
|
for i in range(len(attrs)):
|
||||||
|
if attrs.item(i).nodeValue == 'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd':
|
||||||
|
FoundNamespace = True
|
||||||
|
break
|
||||||
|
self.assertEquals(True, FoundNamespace,
|
||||||
|
"Did not find Sodipodi namespace declaration when using --keep-editor-data")
|
||||||
|
return False
|
||||||
|
|
||||||
class KeepReferencedFonts(unittest.TestCase):
|
class KeepReferencedFonts(unittest.TestCase):
|
||||||
def runTest(self):
|
def runTest(self):
|
||||||
doc = scour.scourXmlFile('unittests/referenced-font.svg')
|
doc = scour.scourXmlFile('unittests/referenced-font.svg')
|
||||||
|
|
@ -611,6 +640,7 @@ class AlwaysKeepClosePathSegments(unittest.TestCase):
|
||||||
# TODO: write tests for --set-precision for path data, for polygon data, for attributes
|
# TODO: write tests for --set-precision for path data, for polygon data, for attributes
|
||||||
# TODO; write a test for embedding rasters
|
# TODO; write a test for embedding rasters
|
||||||
# TODO: write a test for --disable-embed-rasters
|
# TODO: write a test for --disable-embed-rasters
|
||||||
|
# TODO: write tests for --keep-editor-data
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue