From 43c5315004113eda7c79aaae3d1a5f7590019f03 Mon Sep 17 00:00:00 2001 From: Scott Pakin Date: Sat, 16 Nov 2024 16:58:21 -0700 Subject: [PATCH] Split the test file into render + write This split ensures that different names can be given to the empty-command-line test that inkex.tester includes by default. This is important because SimpleInkscapeScripting and SvgToPythonScript produce different output when given no command-line options. New "golden" outputs (*.out) have been generated with Inkscape 1.4. --- tests/data/refs/sis.out | 38 ------------------- .../sis__009fa6028769d24916a9e6032dc9d122.out | 4 +- .../sis__082a949c332e7677145587b68e1a7658.out | 4 +- .../sis__0b76cdb52daf3cd259f54efc1e0643b7.out | 4 +- .../sis__10926e00f595eea8f68837c808aae5d9.out | 4 +- .../sis__11ddf183b35dc6e1dd0c991d99226b08.out | 0 .../sis__285015e789081b1946dc8847f1a8f476.out | 4 +- .../sis__524274119850e3572502388cf161dc6e.out | 4 +- .../sis__52ccca6289d454b91a0efe640abe275d.out | 4 +- .../sis__6249fdcf4e8d2f996de67f93bcba03ee.out | 4 +- .../sis__62f59a6f2ce8aecf0aa594a2267ff08f.out | 4 +- .../sis__7b2a331532fd7385b9a464c44790a3a8.out | 4 +- .../sis__9daf8bee7e10e3969dad9d51212ffb11.out | 2 +- .../sis__a51e0e0e6abd158dd1fbe12f324618ac.out | 4 +- .../sis__a8a14503fa73684f2bb6949311274abd.out | 4 +- .../sis__d6afb6f35b4789832202c36e63a885ae.out | 4 +- .../sis__e462bf312508280d60d701947a61ebf8.out | 4 +- .../sis__ee0834771a765984e2f2926ab4ea5528.out | 4 +- .../sis__ef33d701bbcdd54dc1e6400a2e728f20.out | 4 +- .../sis__f1c2d970ef57f8a777751361dcb310f5.out | 2 +- .../sis__fe44e275e58a5ebdceea22e9e6575d7e.out | 4 +- tests/data/refs/sispy.out | 37 ++++++++++++++++++ ...ispy__11ddf183b35dc6e1dd0c991d99226b08.out | 37 ++++++++++++++++++ tests/test_simple_inkscape_scripting.py | 7 ---- tests/test_svg_to_simp_ink_script.py | 37 ++++++++++++++++++ 25 files changed, 147 insertions(+), 81 deletions(-) create mode 100644 tests/data/refs/sis__11ddf183b35dc6e1dd0c991d99226b08.out create mode 100644 tests/data/refs/sispy.out create mode 100644 tests/data/refs/sispy__11ddf183b35dc6e1dd0c991d99226b08.out create mode 100644 tests/test_svg_to_simp_ink_script.py diff --git a/tests/data/refs/sis.out b/tests/data/refs/sis.out index 88626f4..e69de29 100644 --- a/tests/data/refs/sis.out +++ b/tests/data/refs/sis.out @@ -1,38 +0,0 @@ -################################################### -# This Python script is intended to be run from # -# Inkscape's Simple Inkscape Scripting extension. # -################################################### - -# Prepare the canvas. -#canvas.true_width = 1000 -#canvas.true_height = 1000 -#canvas.viewbox = [0.0, 0.0, 1000.0, 1000.0] - -# Generate an image. -path859 = path([Move(8.7185878, 4.0337352), Line(-2.2072895, 0.016013256), Line(8.7185884, -4.0017078), Curve(6.97309, -1.6296469, 6.9831476, 1.6157441, 8.7185878, 4.0337352), zoneClose()], transform='matrix(1.1 0 0 1.1 1.1 0)', fill='#000000', fill_rule='evenodd', stroke_width=0.625, stroke_linejoin='round', stroke_opacity=1, fill_opacity=1) -Arrow2Lstart = marker(path859, ref=(0.0, 0.0), orient='auto', overflow='visible') -rect((651.3089, 353.92661), (900.00002, 555.42472), stroke='none', fill='#ff0000', opacity=0.5, stroke_width=1.11927199) -circle((150, 450), 50, stroke='none', fill='#000080', display='inline') -ellipse((400, 450), (100, 50), stroke='#ff0000', display='inline', stroke_width=16) -arc((700, 450), (100, 50), (0.59013865, 5.6484511), arc_type='slice', stroke='#008000', fill='#ffff00', display='inline', stroke_width=16) -path([Move(100.0, 600.0), Line(200.0, 700.0), Line(300.0, 600.0), Line(400.0, 700.0)], display='inline', stroke_width=10, marker_start=Arrow2Lstart) -path([move(500.0, 600.0), curve(0.0, 0.0, 0.0, 100.0, 100.0, 100.0), curve(100.0, 0.0, 0.0, -100.0, 100.0, -100.0), curve(100.0, 0.0, 100.0, 100.0, 100.0, 100.0)], display='inline', stroke_width=10) -s1 = star(5, (189.03001, 847.93945), (69.364868, 34.682434), angles=(0.63598373, 1.2643023), stroke='#008000', fill='#ffff00', display='inline', stroke_width=10) -clone(s1, transform='translate(200, 2.99622)', display='inline') -t1 = text('', (100, 100), font_size='14.66666698px', line_height=1.25, font_family='sans-serif', fill='#000000', stroke='none') -t1.add_text('Hello World', (100, 100)) -rect((105.71429, 219.66254), (370.28179, 481.82441), stroke=None, fill=None) -t2 = text('', (200, 100), font_size='14.66666698px', line_height=1.25, font_family='sans-serif', fill='#000000', stroke='none') -t2.add_text('UPPER', (200, 100), font_size='14.66666698px') -t3 = text('', (300, 100), font_size='10.58333302px', line_height=1.25, font_family='sans-serif', fill='#000000', stroke='none') -t3.add_text('Multi line', (300, 100), font_size='14.66666698px') -t3.add_text('text', (300, 118.33334), font_size='14.66666698px') -t3.add_text('FOO', (300, 136.66667), font_size='14.66666698px') -text3762 = text('', (54.289616, 229.64807), font_size='10.58333302px', line_height=1.25, font_family='sans-serif', fill='#000000', stroke='none') -text3762.add_text('Grouped', (54.289616, 229.64807), font_size='14.66666698px') -text3766 = text('', (54.289619, 259.64807), font_size='14.66666698px', line_height=1.25, font_family='sans-serif', fill='#000000', stroke='none') -text3766.add_text('text', (54.289619, 259.64807), font_size='14.66666698px') -group([text3762, text3766], transform='translate(445.71, -129.648)') -rect((100, 200), (200, 300), stroke='none', fill='#000080') -rect((300, 200), (500, 300), stroke='#ff0000', stroke_width=16) -rect((600, 200), (800, 300), round=(44.943226, 38.950798), stroke='#008000', fill='#ffff00', stroke_width=16) diff --git a/tests/data/refs/sis__009fa6028769d24916a9e6032dc9d122.out b/tests/data/refs/sis__009fa6028769d24916a9e6032dc9d122.out index 60de932..98e5dfe 100644 --- a/tests/data/refs/sis__009fa6028769d24916a9e6032dc9d122.out +++ b/tests/data/refs/sis__009fa6028769d24916a9e6032dc9d122.out @@ -1,4 +1,4 @@ - + @@ -9,5 +9,5 @@ - + \ No newline at end of file diff --git a/tests/data/refs/sis__082a949c332e7677145587b68e1a7658.out b/tests/data/refs/sis__082a949c332e7677145587b68e1a7658.out index 4f02228..e792853 100644 --- a/tests/data/refs/sis__082a949c332e7677145587b68e1a7658.out +++ b/tests/data/refs/sis__082a949c332e7677145587b68e1a7658.out @@ -1,5 +1,5 @@ - + @@ -9,5 +9,5 @@ - + \ No newline at end of file diff --git a/tests/data/refs/sis__0b76cdb52daf3cd259f54efc1e0643b7.out b/tests/data/refs/sis__0b76cdb52daf3cd259f54efc1e0643b7.out index 9af0215..b55b3d5 100644 --- a/tests/data/refs/sis__0b76cdb52daf3cd259f54efc1e0643b7.out +++ b/tests/data/refs/sis__0b76cdb52daf3cd259f54efc1e0643b7.out @@ -1,4 +1,4 @@ - + @@ -9,5 +9,5 @@ - + \ No newline at end of file diff --git a/tests/data/refs/sis__10926e00f595eea8f68837c808aae5d9.out b/tests/data/refs/sis__10926e00f595eea8f68837c808aae5d9.out index afb9b0b..b0678b3 100644 --- a/tests/data/refs/sis__10926e00f595eea8f68837c808aae5d9.out +++ b/tests/data/refs/sis__10926e00f595eea8f68837c808aae5d9.out @@ -1,4 +1,4 @@ - + @@ -9,5 +9,5 @@ - + \ No newline at end of file diff --git a/tests/data/refs/sis__11ddf183b35dc6e1dd0c991d99226b08.out b/tests/data/refs/sis__11ddf183b35dc6e1dd0c991d99226b08.out new file mode 100644 index 0000000..e69de29 diff --git a/tests/data/refs/sis__285015e789081b1946dc8847f1a8f476.out b/tests/data/refs/sis__285015e789081b1946dc8847f1a8f476.out index f436da9..ca86547 100644 --- a/tests/data/refs/sis__285015e789081b1946dc8847f1a8f476.out +++ b/tests/data/refs/sis__285015e789081b1946dc8847f1a8f476.out @@ -1,4 +1,4 @@ - + @@ -9,5 +9,5 @@ - + \ No newline at end of file diff --git a/tests/data/refs/sis__524274119850e3572502388cf161dc6e.out b/tests/data/refs/sis__524274119850e3572502388cf161dc6e.out index 888a8d5..d444bf3 100644 --- a/tests/data/refs/sis__524274119850e3572502388cf161dc6e.out +++ b/tests/data/refs/sis__524274119850e3572502388cf161dc6e.out @@ -1,4 +1,4 @@ - + @@ -9,5 +9,5 @@ - + \ No newline at end of file diff --git a/tests/data/refs/sis__52ccca6289d454b91a0efe640abe275d.out b/tests/data/refs/sis__52ccca6289d454b91a0efe640abe275d.out index eb1a0df..f1da3df 100644 --- a/tests/data/refs/sis__52ccca6289d454b91a0efe640abe275d.out +++ b/tests/data/refs/sis__52ccca6289d454b91a0efe640abe275d.out @@ -1,4 +1,4 @@ - + @@ -9,5 +9,5 @@ - + \ No newline at end of file diff --git a/tests/data/refs/sis__6249fdcf4e8d2f996de67f93bcba03ee.out b/tests/data/refs/sis__6249fdcf4e8d2f996de67f93bcba03ee.out index 9e3d238..ed5006b 100644 --- a/tests/data/refs/sis__6249fdcf4e8d2f996de67f93bcba03ee.out +++ b/tests/data/refs/sis__6249fdcf4e8d2f996de67f93bcba03ee.out @@ -1,5 +1,5 @@ - + @@ -9,5 +9,5 @@ - + \ No newline at end of file diff --git a/tests/data/refs/sis__62f59a6f2ce8aecf0aa594a2267ff08f.out b/tests/data/refs/sis__62f59a6f2ce8aecf0aa594a2267ff08f.out index 3cb43c1..a475d48 100644 --- a/tests/data/refs/sis__62f59a6f2ce8aecf0aa594a2267ff08f.out +++ b/tests/data/refs/sis__62f59a6f2ce8aecf0aa594a2267ff08f.out @@ -1,4 +1,4 @@ - + @@ -9,5 +9,5 @@ - + \ No newline at end of file diff --git a/tests/data/refs/sis__7b2a331532fd7385b9a464c44790a3a8.out b/tests/data/refs/sis__7b2a331532fd7385b9a464c44790a3a8.out index 3a6553e..256332c 100644 --- a/tests/data/refs/sis__7b2a331532fd7385b9a464c44790a3a8.out +++ b/tests/data/refs/sis__7b2a331532fd7385b9a464c44790a3a8.out @@ -1,4 +1,4 @@ - + @@ -9,5 +9,5 @@ - + \ No newline at end of file diff --git a/tests/data/refs/sis__9daf8bee7e10e3969dad9d51212ffb11.out b/tests/data/refs/sis__9daf8bee7e10e3969dad9d51212ffb11.out index ea9d2ff..6bb2009 100644 --- a/tests/data/refs/sis__9daf8bee7e10e3969dad9d51212ffb11.out +++ b/tests/data/refs/sis__9daf8bee7e10e3969dad9d51212ffb11.out @@ -19,7 +19,7 @@ layout-position-anchor: tl - + diff --git a/tests/data/refs/sis__a51e0e0e6abd158dd1fbe12f324618ac.out b/tests/data/refs/sis__a51e0e0e6abd158dd1fbe12f324618ac.out index 34604b2..1c155b5 100644 --- a/tests/data/refs/sis__a51e0e0e6abd158dd1fbe12f324618ac.out +++ b/tests/data/refs/sis__a51e0e0e6abd158dd1fbe12f324618ac.out @@ -1,4 +1,4 @@ - + @@ -9,5 +9,5 @@ - + \ No newline at end of file diff --git a/tests/data/refs/sis__a8a14503fa73684f2bb6949311274abd.out b/tests/data/refs/sis__a8a14503fa73684f2bb6949311274abd.out index 8eec572..085c420 100644 --- a/tests/data/refs/sis__a8a14503fa73684f2bb6949311274abd.out +++ b/tests/data/refs/sis__a8a14503fa73684f2bb6949311274abd.out @@ -1,4 +1,4 @@ - + @@ -9,5 +9,5 @@ - + \ No newline at end of file diff --git a/tests/data/refs/sis__d6afb6f35b4789832202c36e63a885ae.out b/tests/data/refs/sis__d6afb6f35b4789832202c36e63a885ae.out index 3aaf4e8..01c6050 100644 --- a/tests/data/refs/sis__d6afb6f35b4789832202c36e63a885ae.out +++ b/tests/data/refs/sis__d6afb6f35b4789832202c36e63a885ae.out @@ -1,4 +1,4 @@ - + @@ -9,5 +9,5 @@ - + \ No newline at end of file diff --git a/tests/data/refs/sis__e462bf312508280d60d701947a61ebf8.out b/tests/data/refs/sis__e462bf312508280d60d701947a61ebf8.out index 2e8858a..9b95341 100644 --- a/tests/data/refs/sis__e462bf312508280d60d701947a61ebf8.out +++ b/tests/data/refs/sis__e462bf312508280d60d701947a61ebf8.out @@ -1,4 +1,4 @@ - + @@ -9,5 +9,5 @@ - + \ No newline at end of file diff --git a/tests/data/refs/sis__ee0834771a765984e2f2926ab4ea5528.out b/tests/data/refs/sis__ee0834771a765984e2f2926ab4ea5528.out index a51c45f..81335cd 100644 --- a/tests/data/refs/sis__ee0834771a765984e2f2926ab4ea5528.out +++ b/tests/data/refs/sis__ee0834771a765984e2f2926ab4ea5528.out @@ -1,5 +1,5 @@ - + @@ -9,5 +9,5 @@ - + \ No newline at end of file diff --git a/tests/data/refs/sis__ef33d701bbcdd54dc1e6400a2e728f20.out b/tests/data/refs/sis__ef33d701bbcdd54dc1e6400a2e728f20.out index 7ba89ef..a1eced1 100644 --- a/tests/data/refs/sis__ef33d701bbcdd54dc1e6400a2e728f20.out +++ b/tests/data/refs/sis__ef33d701bbcdd54dc1e6400a2e728f20.out @@ -1,4 +1,4 @@ - + @@ -9,5 +9,5 @@ - + \ No newline at end of file diff --git a/tests/data/refs/sis__f1c2d970ef57f8a777751361dcb310f5.out b/tests/data/refs/sis__f1c2d970ef57f8a777751361dcb310f5.out index d38c118..a59da61 100644 --- a/tests/data/refs/sis__f1c2d970ef57f8a777751361dcb310f5.out +++ b/tests/data/refs/sis__f1c2d970ef57f8a777751361dcb310f5.out @@ -9,5 +9,5 @@ - + \ No newline at end of file diff --git a/tests/data/refs/sis__fe44e275e58a5ebdceea22e9e6575d7e.out b/tests/data/refs/sis__fe44e275e58a5ebdceea22e9e6575d7e.out index 842e3a7..ebc9a45 100644 --- a/tests/data/refs/sis__fe44e275e58a5ebdceea22e9e6575d7e.out +++ b/tests/data/refs/sis__fe44e275e58a5ebdceea22e9e6575d7e.out @@ -1,4 +1,4 @@ - + @@ -9,5 +9,5 @@ - + \ No newline at end of file diff --git a/tests/data/refs/sispy.out b/tests/data/refs/sispy.out new file mode 100644 index 0000000..4e7b805 --- /dev/null +++ b/tests/data/refs/sispy.out @@ -0,0 +1,37 @@ +################################################### +# This Python script is intended to be run from # +# Inkscape's Simple Inkscape Scripting extension. # +################################################### + +# Prepare the canvas. +#canvas.true_width = 1000 +#canvas.true_height = 1000 +#canvas.viewbox = [0.0, 0.0, 1000.0, 1000.0] + +# Generate an image. +path859 = path([Move(8.7185878, 4.0337352), Line(-2.2072895, 0.016013256), Line(8.7185884, -4.0017078), Curve(6.97309, -1.6296469, 6.9831476, 1.6157441, 8.7185878, 4.0337352), zoneClose()], transform='matrix(1.1 0 0 1.1 1.1 0)', fill='#000000', fill_rule='evenodd', stroke_width=0.625, stroke_linejoin='round', stroke_opacity=1, fill_opacity=1) +rect((651.3089, 353.92661), (900.00002, 555.42472), stroke='none', fill='#ff0000', opacity=0.5, stroke_width=1.11927199) +circle((150, 450), 50, stroke='none', fill='#000080', display='inline') +ellipse((400, 450), (100, 50), stroke='#ff0000', display='inline', stroke_width=16) +arc((700, 450), (100, 50), (0.59013865, 5.6484511), arc_type='slice', stroke='#008000', fill='#ffff00', display='inline', stroke_width=16) +path([Move(100.0, 600.0), Line(200.0, 700.0), Line(300.0, 600.0), Line(400.0, 700.0)], display='inline', stroke_width=10, marker_start='url("#Arrow2Lstart")') +path([move(500.0, 600.0), curve(0.0, 0.0, 0.0, 100.0, 100.0, 100.0), curve(100.0, 0.0, 0.0, -100.0, 100.0, -100.0), curve(100.0, 0.0, 100.0, 100.0, 100.0, 100.0)], display='inline', stroke_width=10) +s1 = star(5, (189.03001, 847.93945), (69.364868, 34.682434), angles=(0.63598373, 1.2643023), stroke='#008000', fill='#ffff00', display='inline', stroke_width=10) +clone(s1, transform='translate(200, 2.99622)', display='inline') +t1 = text('', (100, 100), font_size='14.66666698px', line_height=1.25, font_family='sans-serif', fill='#000000', stroke='none') +t1.add_text('Hello World', (100, 100)) +rect((105.71429, 219.66254), (370.28179, 481.82441), stroke=None, fill=None) +t2 = text('', (200, 100), font_size='14.66666698px', line_height=1.25, font_family='sans-serif', fill='#000000', stroke='none') +t2.add_text('UPPER', (200, 100), font_size='14.66666698px') +t3 = text('', (300, 100), font_size='10.58333302px', line_height=1.25, font_family='sans-serif', fill='#000000', stroke='none') +t3.add_text('Multi line', (300, 100), font_size='14.66666698px') +t3.add_text('text', (300, 118.33334), font_size='14.66666698px') +t3.add_text('FOO', (300, 136.66667), font_size='14.66666698px') +text3762 = text('', (54.289616, 229.64807), font_size='10.58333302px', line_height=1.25, font_family='sans-serif', fill='#000000', stroke='none') +text3762.add_text('Grouped', (54.289616, 229.64807), font_size='14.66666698px') +text3766 = text('', (54.289619, 259.64807), font_size='14.66666698px', line_height=1.25, font_family='sans-serif', fill='#000000', stroke='none') +text3766.add_text('text', (54.289619, 259.64807), font_size='14.66666698px') +group([text3762, text3766], transform='translate(445.71, -129.648)') +rect((100, 200), (200, 300), stroke='none', fill='#000080') +rect((300, 200), (500, 300), stroke='#ff0000', stroke_width=16) +rect((600, 200), (800, 300), round=(44.943226, 38.950798), stroke='#008000', fill='#ffff00', stroke_width=16) diff --git a/tests/data/refs/sispy__11ddf183b35dc6e1dd0c991d99226b08.out b/tests/data/refs/sispy__11ddf183b35dc6e1dd0c991d99226b08.out new file mode 100644 index 0000000..4e7b805 --- /dev/null +++ b/tests/data/refs/sispy__11ddf183b35dc6e1dd0c991d99226b08.out @@ -0,0 +1,37 @@ +################################################### +# This Python script is intended to be run from # +# Inkscape's Simple Inkscape Scripting extension. # +################################################### + +# Prepare the canvas. +#canvas.true_width = 1000 +#canvas.true_height = 1000 +#canvas.viewbox = [0.0, 0.0, 1000.0, 1000.0] + +# Generate an image. +path859 = path([Move(8.7185878, 4.0337352), Line(-2.2072895, 0.016013256), Line(8.7185884, -4.0017078), Curve(6.97309, -1.6296469, 6.9831476, 1.6157441, 8.7185878, 4.0337352), zoneClose()], transform='matrix(1.1 0 0 1.1 1.1 0)', fill='#000000', fill_rule='evenodd', stroke_width=0.625, stroke_linejoin='round', stroke_opacity=1, fill_opacity=1) +rect((651.3089, 353.92661), (900.00002, 555.42472), stroke='none', fill='#ff0000', opacity=0.5, stroke_width=1.11927199) +circle((150, 450), 50, stroke='none', fill='#000080', display='inline') +ellipse((400, 450), (100, 50), stroke='#ff0000', display='inline', stroke_width=16) +arc((700, 450), (100, 50), (0.59013865, 5.6484511), arc_type='slice', stroke='#008000', fill='#ffff00', display='inline', stroke_width=16) +path([Move(100.0, 600.0), Line(200.0, 700.0), Line(300.0, 600.0), Line(400.0, 700.0)], display='inline', stroke_width=10, marker_start='url("#Arrow2Lstart")') +path([move(500.0, 600.0), curve(0.0, 0.0, 0.0, 100.0, 100.0, 100.0), curve(100.0, 0.0, 0.0, -100.0, 100.0, -100.0), curve(100.0, 0.0, 100.0, 100.0, 100.0, 100.0)], display='inline', stroke_width=10) +s1 = star(5, (189.03001, 847.93945), (69.364868, 34.682434), angles=(0.63598373, 1.2643023), stroke='#008000', fill='#ffff00', display='inline', stroke_width=10) +clone(s1, transform='translate(200, 2.99622)', display='inline') +t1 = text('', (100, 100), font_size='14.66666698px', line_height=1.25, font_family='sans-serif', fill='#000000', stroke='none') +t1.add_text('Hello World', (100, 100)) +rect((105.71429, 219.66254), (370.28179, 481.82441), stroke=None, fill=None) +t2 = text('', (200, 100), font_size='14.66666698px', line_height=1.25, font_family='sans-serif', fill='#000000', stroke='none') +t2.add_text('UPPER', (200, 100), font_size='14.66666698px') +t3 = text('', (300, 100), font_size='10.58333302px', line_height=1.25, font_family='sans-serif', fill='#000000', stroke='none') +t3.add_text('Multi line', (300, 100), font_size='14.66666698px') +t3.add_text('text', (300, 118.33334), font_size='14.66666698px') +t3.add_text('FOO', (300, 136.66667), font_size='14.66666698px') +text3762 = text('', (54.289616, 229.64807), font_size='10.58333302px', line_height=1.25, font_family='sans-serif', fill='#000000', stroke='none') +text3762.add_text('Grouped', (54.289616, 229.64807), font_size='14.66666698px') +text3766 = text('', (54.289619, 259.64807), font_size='14.66666698px', line_height=1.25, font_family='sans-serif', fill='#000000', stroke='none') +text3766.add_text('text', (54.289619, 259.64807), font_size='14.66666698px') +group([text3762, text3766], transform='translate(445.71, -129.648)') +rect((100, 200), (200, 300), stroke='none', fill='#000080') +rect((300, 200), (500, 300), stroke='#ff0000', stroke_width=16) +rect((600, 200), (800, 300), round=(44.943226, 38.950798), stroke='#008000', fill='#ffff00', stroke_width=16) diff --git a/tests/test_simple_inkscape_scripting.py b/tests/test_simple_inkscape_scripting.py index dee14d8..8458502 100644 --- a/tests/test_simple_inkscape_scripting.py +++ b/tests/test_simple_inkscape_scripting.py @@ -4,7 +4,6 @@ ############################################################# from simpinkscr.simple_inkscape_scripting import SimpleInkscapeScripting -from simpinkscr.svg_to_simp_ink_script import SvgToPythonScript from inkex.tester import ComparisonMixin, InkscapeExtensionTestMixin, TestCase from inkex.tester.filters import CompareOrderIndependentStyle from unittest.mock import patch @@ -539,12 +538,6 @@ class SimpInkScrModifyTest(CustomComparisonMixin, ] -class SimpInkScrOutputBasicTest(CustomComparisonMixin, TestCase): - effect_class = SvgToPythonScript - compare_file = 'svg/shapes.svg' - comparisons = [()] - - class SimpInkScrCmdlineArgsTest(TestCase): effect_class = SimpleInkscapeScripting diff --git a/tests/test_svg_to_simp_ink_script.py b/tests/test_svg_to_simp_ink_script.py new file mode 100644 index 0000000..0698ce7 --- /dev/null +++ b/tests/test_svg_to_simp_ink_script.py @@ -0,0 +1,37 @@ +################################################## +# Define a set of unit tests for Simple Inkscape # +# Scripting's Python output # +# # +# Author: Scott Pakin # +################################################## + +from simpinkscr.svg_to_simp_ink_script import SvgToPythonScript +from inkex.tester import ComparisonMixin, TestCase +import hashlib +import re + + +class CustomComparisonMixin(ComparisonMixin): + def get_compare_cmpfile(self, args, addout=None): + """Generate an output file for the arguments given""" + if addout is not None: + args = list(args) + [str(addout)] + opstr = ( + "__".join(args) + .replace(self.tempdir, "TMP_DIR") + .replace(self.datadir(), "DAT_DIR") + ) + opstr = re.sub(r"[^\w-]", "__", opstr) + if opstr: + # Modification from ComparisonMixin: always hash. + opstr = hashlib.md5(opstr.encode("latin1")).hexdigest() + opstr = "__" + opstr + return self.data_file( + "refs", f"sispy{opstr}.out", check_exists=False + ) + + +class SimpInkScrOutputBasicTest(CustomComparisonMixin, TestCase): + effect_class = SvgToPythonScript + compare_file = 'svg/shapes.svg' + comparisons = [()]