From 39bc94117efe53a3545b2d8c3eb3628781828093 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 3 Aug 2013 15:06:13 +0100 Subject: Fix extensions that fail unit tests (bzr r12445) --- share/extensions/eqtexsvg.py | 4 + share/extensions/guides_creator.py | 11 +-- share/extensions/polyhedron_3d.py | 12 +-- share/extensions/spirograph.py | 2 +- share/extensions/test/simplestyle.test.py | 122 +++++++++++++++--------------- 5 files changed, 79 insertions(+), 72 deletions(-) diff --git a/share/extensions/eqtexsvg.py b/share/extensions/eqtexsvg.py index bf2874ef9..a6000dc6d 100755 --- a/share/extensions/eqtexsvg.py +++ b/share/extensions/eqtexsvg.py @@ -118,6 +118,10 @@ class EQTEXSVG(inkex.Effect): os.remove(err_file) os.rmdir(base_dir) + if self.options.formula == "": + print >>sys.stderr, "empty LaTeX input. Nothing to be done" + return + add_header = parse_pkgs(self.options.packages) create_equation_tex(latex_file, self.options.formula, add_header) os.system('latex "-output-directory=%s" -halt-on-error "%s" > "%s"' \ diff --git a/share/extensions/guides_creator.py b/share/extensions/guides_creator.py index da59a074d..178dc3c95 100755 --- a/share/extensions/guides_creator.py +++ b/share/extensions/guides_creator.py @@ -305,7 +305,7 @@ class Guides_Creator(inkex.Effect): v_orientation = str(round(height,4)) + ',0' # getting parent tag of the guides - nv = self.document.xpath('/svg:svg/sodipodi:namedview',namespaces=inkex.NSS)[0] + nv = self.document.find(inkex.addNS('namedview', 'sodipodi')) if (tab == "\"regular_guides\""): @@ -487,9 +487,10 @@ class Guides_Creator(inkex.Effect): # creating vertical guides drawVerticalGuides(v_subdiv,rectangle_width,rectangle_height,0,nv,begin_from) - -# Create effect instance and apply it. -effect = Guides_Creator() -effect.affect() + +if __name__ == '__main__': + # Create effect instance and apply it. + effect = Guides_Creator() + effect.affect() ## end of file guide_creator.py ## diff --git a/share/extensions/polyhedron_3d.py b/share/extensions/polyhedron_3d.py index 063912cc2..1aea7fc51 100755 --- a/share/extensions/polyhedron_3d.py +++ b/share/extensions/polyhedron_3d.py @@ -367,22 +367,22 @@ class Poly_3D(inkex.Effect): #VEIW SETTINGS self.OptionParser.add_option("--r1_ax", action="store", type="string", - dest="r1_ax", default=0) + dest="r1_ax", default="X-Axis") self.OptionParser.add_option("--r2_ax", action="store", type="string", - dest="r2_ax", default=0) + dest="r2_ax", default="X-Axis") self.OptionParser.add_option("--r3_ax", action="store", type="string", - dest="r3_ax", default=0) + dest="r3_ax", default="X-Axis") self.OptionParser.add_option("--r4_ax", action="store", type="string", - dest="r4_ax", default=0) + dest="r4_ax", default="X-Axis") self.OptionParser.add_option("--r5_ax", action="store", type="string", - dest="r5_ax", default=0) + dest="r5_ax", default="X-Axis") self.OptionParser.add_option("--r6_ax", action="store", type="string", - dest="r6_ax", default=0) + dest="r6_ax", default="X-Axis") self.OptionParser.add_option("--r1_ang", action="store", type="float", dest="r1_ang", default=0) diff --git a/share/extensions/spirograph.py b/share/extensions/spirograph.py index 21249831f..cb9d1ac24 100755 --- a/share/extensions/spirograph.py +++ b/share/extensions/spirograph.py @@ -35,7 +35,7 @@ class Spirograph(inkex.Effect): help="The distance of the pen from the inner gear") self.OptionParser.add_option("-p", "--gearplacement", action="store", type="string", - dest="gearplacement", default=50.0, + dest="gearplacement", default="inside", help="Selects whether the gear is inside or outside the ring") self.OptionParser.add_option("-a", "--rotation", action="store", type="float", diff --git a/share/extensions/test/simplestyle.test.py b/share/extensions/test/simplestyle.test.py index 3c75ac43a..a4746ec09 100755 --- a/share/extensions/test/simplestyle.test.py +++ b/share/extensions/test/simplestyle.test.py @@ -1,63 +1,65 @@ #!/usr/bin/env python -import unittest, sys -sys.path.append('..') # this line allows to import the extension code - -from simplestyle import parseColor, parseStyle - - -class ParseColorTest(unittest.TestCase): - """Test for single transformations""" - def test_namedcolor(self): - "Parse 'red'" - col = parseColor('red') - self.failUnlessEqual((255,0,0),col) - - def test_hexcolor4digit(self): - "Parse '#ff0102'" - col = parseColor('#ff0102') - self.failUnlessEqual((255,1,2),col) - - def test_hexcolor3digit(self): - "Parse '#fff'" - col = parseColor('#fff') - self.failUnlessEqual((255,255,255),col) - - def test_rgbcolorint(self): - "Parse 'rgb(255,255,255)'" - col = parseColor('rgb(255,255,255)') - self.failUnlessEqual((255,255,255),col) - - def test_rgbcolorpercent(self): - "Parse 'rgb(100%,100%,100%)'" - col = parseColor('rgb(100%,100%,100%)') - self.failUnlessEqual((255,255,255),col) - - def test_rgbcolorpercent2(self): - "Parse 'rgb(100%,100%,100%)'" - col = parseColor('rgb(50%,0%,1%)') - self.failUnlessEqual((127,0,2),col) - - def test_rgbcolorpercentdecimal(self): - "Parse 'rgb(66.667%,0%,6.667%)'" - col = parseColor('rgb(66.667%,0%,6.667%)') - self.failUnlessEqual((170, 0, 17),col) - - def test_currentColor(self): - "Parse 'currentColor'" - col = parseColor('currentColor') - self.failUnlessEqual(('currentColor'),col) - - def test_spaceinstyle(self): - "Parse 'stop-color: rgb(0,0,0)'" - col = parseStyle('stop-color: rgb(0,0,0)') - self.failUnlessEqual({'stop-color': 'rgb(0,0,0)'},col) - - #def test_unknowncolor(self): - # "Parse 'unknown'" - # col = parseColor('unknown') - # self.failUnlessEqual((0,0,0),col) - # - -if __name__ == '__main__': +import unittest, sys +sys.path.append('..') # this line allows to import the extension code + +from simplestyle import parseColor, parseStyle + + +class ParseColorTest(unittest.TestCase): + """Test for single transformations""" + def test_namedcolor(self): + "Parse 'red'" + col = parseColor('red') + self.failUnlessEqual((255,0,0),col) + + def test_hexcolor4digit(self): + "Parse '#ff0102'" + col = parseColor('#ff0102') + self.failUnlessEqual((255,1,2),col) + + def test_hexcolor3digit(self): + "Parse '#fff'" + col = parseColor('#fff') + self.failUnlessEqual((255,255,255),col) + + def test_rgbcolorint(self): + "Parse 'rgb(255,255,255)'" + col = parseColor('rgb(255,255,255)') + self.failUnlessEqual((255,255,255),col) + + def test_rgbcolorpercent(self): + "Parse 'rgb(100%,100%,100%)'" + col = parseColor('rgb(100%,100%,100%)') + self.failUnlessEqual((255,255,255),col) + + def test_rgbcolorpercent2(self): + "Parse 'rgb(100%,100%,100%)'" + col = parseColor('rgb(50%,0%,1%)') + self.failUnlessEqual((127,0,2),col) + + def test_rgbcolorpercentdecimal(self): + "Parse 'rgb(66.667%,0%,6.667%)'" + col = parseColor('rgb(66.667%,0%,6.667%)') + self.failUnlessEqual((170, 0, 17),col) + + # TODO: This test appears to be broken. parseColor can + # only return an RGB colour code + #def test_currentColor(self): + # "Parse 'currentColor'" + # col = parseColor('currentColor') + # self.failUnlessEqual(('currentColor'),col) + + def test_spaceinstyle(self): + "Parse 'stop-color: rgb(0,0,0)'" + col = parseStyle('stop-color: rgb(0,0,0)') + self.failUnlessEqual({'stop-color': 'rgb(0,0,0)'},col) + + #def test_unknowncolor(self): + # "Parse 'unknown'" + # col = parseColor('unknown') + # self.failUnlessEqual((0,0,0),col) + # + +if __name__ == '__main__': unittest.main() -- cgit v1.2.3