From db275288d99e401a1eee35feb955d41db9ab7fa3 Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Tue, 9 Jul 2019 21:41:33 -0700 Subject: [PATCH] pylint3 cleanup of unit tests --- src/Mod/Path/PathTests/TestPathDeburr.py | 1 - .../Path/PathTests/TestPathDressupDogbone.py | 47 +++++++++---------- .../PathTests/TestPathDressupHoldingTags.py | 10 ++-- src/Mod/Path/PathTests/TestPathGeom.py | 10 ---- src/Mod/Path/PathTests/TestPathLog.py | 6 +-- src/Mod/Path/PathTests/TestPathOpTools.py | 3 +- src/Mod/Path/PathTests/TestPathPost.py | 13 ++--- src/Mod/Path/PathTests/TestPathSetupSheet.py | 1 - src/Mod/Path/PathTests/TestPathStock.py | 2 - src/Mod/Path/PathTests/TestPathTool.py | 1 - src/Mod/Path/PathTests/TestPathTooltable.py | 1 - src/Mod/Path/PathTests/TestPathUtil.py | 3 -- src/Mod/Path/utils/path-lint.sh | 6 ++- 13 files changed, 39 insertions(+), 65 deletions(-) diff --git a/src/Mod/Path/PathTests/TestPathDeburr.py b/src/Mod/Path/PathTests/TestPathDeburr.py index d94963407d..aecb2ee181 100644 --- a/src/Mod/Path/PathTests/TestPathDeburr.py +++ b/src/Mod/Path/PathTests/TestPathDeburr.py @@ -26,7 +26,6 @@ import Path import PathScripts.PathDeburr as PathDeburr import PathScripts.PathLog as PathLog import PathTests.PathTestUtils as PathTestUtils -import math PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) #PathLog.trackModule(PathLog.thisModule()) diff --git a/src/Mod/Path/PathTests/TestPathDressupDogbone.py b/src/Mod/Path/PathTests/TestPathDressupDogbone.py index 55759fdf13..5ab8019038 100644 --- a/src/Mod/Path/PathTests/TestPathDressupDogbone.py +++ b/src/Mod/Path/PathTests/TestPathDressupDogbone.py @@ -24,14 +24,10 @@ import FreeCAD import Path -import PathScripts import PathScripts.PathDressupDogbone as PathDressupDogbone import PathScripts.PathJob as PathJob import PathScripts.PathProfileFaces as PathProfileFaces -import math -import unittest -from FreeCAD import Vector from PathTests.PathTestUtils import PathTestBase class TestProfile: @@ -48,6 +44,7 @@ class TestFeature: self.Path = Path.Path() def addProperty(self, typ, nam, category, tip): + # pylint: disable=unused-argument setattr(self, nam, None) def setEditorMode(self, prop, mode): @@ -61,31 +58,29 @@ class TestDressupDogbone(PathTestBase): def test00(self): '''Verify bones are inserted for simple moves.''' - path = [] base = TestProfile('Inside', 'CW', 'G0 X10 Y10 Z10\nG1 Z0\nG1 Y100\nG1 X12\nG1 Y10\nG1 X10\nG1 Z10') obj = TestFeature() db = PathDressupDogbone.ObjectDressup(obj, base) db.setup(obj, True) db.execute(obj, False) - self.assertEquals(len(db.bones), 4) - self.assertEquals("1: (10.00, 100.00)", self.formatBone(db.bones[0])) - self.assertEquals("2: (12.00, 100.00)", self.formatBone(db.bones[1])) - self.assertEquals("3: (12.00, 10.00)", self.formatBone(db.bones[2])) - self.assertEquals("4: (10.00, 10.00)", self.formatBone(db.bones[3])) + self.assertEqual(len(db.bones), 4) + self.assertEqual("1: (10.00, 100.00)", self.formatBone(db.bones[0])) + self.assertEqual("2: (12.00, 100.00)", self.formatBone(db.bones[1])) + self.assertEqual("3: (12.00, 10.00)", self.formatBone(db.bones[2])) + self.assertEqual("4: (10.00, 10.00)", self.formatBone(db.bones[3])) def test01(self): '''Verify bones are inserted if hole ends with rapid move out.''' - path = [] base = TestProfile('Inside', 'CW', 'G0 X10 Y10 Z10\nG1 Z0\nG1 Y100\nG1 X12\nG1 Y10\nG1 X10\nG0 Z10') obj = TestFeature() db = PathDressupDogbone.ObjectDressup(obj, base) db.setup(obj, True) db.execute(obj, False) - self.assertEquals(len(db.bones), 4) - self.assertEquals("1: (10.00, 100.00)", self.formatBone(db.bones[0])) - self.assertEquals("2: (12.00, 100.00)", self.formatBone(db.bones[1])) - self.assertEquals("3: (12.00, 10.00)", self.formatBone(db.bones[2])) - self.assertEquals("4: (10.00, 10.00)", self.formatBone(db.bones[3])) + self.assertEqual(len(db.bones), 4) + self.assertEqual("1: (10.00, 100.00)", self.formatBone(db.bones[0])) + self.assertEqual("2: (12.00, 100.00)", self.formatBone(db.bones[1])) + self.assertEqual("3: (12.00, 10.00)", self.formatBone(db.bones[2])) + self.assertEqual("4: (10.00, 10.00)", self.formatBone(db.bones[3])) def test02(self): '''Verify bones are correctly generated for a Profile.''' @@ -113,7 +108,7 @@ class TestDressupDogbone(PathTestBase): if f.Surface.Axis == FreeCAD.Vector(0,0,1) and f.Orientation == 'Forward': break - job = PathJob.Create('Job', [cut], None) + PathJob.Create('Job', [cut], None) profile = PathProfileFaces.Create('Profile Faces') profile.Base = (cut, face) @@ -138,14 +133,14 @@ class TestDressupDogbone(PathTestBase): return "(%.2f, %.2f)" % (pt[0], pt[1]) # Make sure we get 8 bones, 2 in each corner (different heights) - self.assertEquals(len(locs), 8) - self.assertEquals("(27.50, 27.50)", formatBoneLoc(locs[0])) - self.assertEquals("(27.50, 27.50)", formatBoneLoc(locs[1])) - self.assertEquals("(27.50, 72.50)", formatBoneLoc(locs[2])) - self.assertEquals("(27.50, 72.50)", formatBoneLoc(locs[3])) - self.assertEquals("(72.50, 27.50)", formatBoneLoc(locs[4])) - self.assertEquals("(72.50, 27.50)", formatBoneLoc(locs[5])) - self.assertEquals("(72.50, 72.50)", formatBoneLoc(locs[6])) - self.assertEquals("(72.50, 72.50)", formatBoneLoc(locs[7])) + self.assertEqual(len(locs), 8) + self.assertEqual("(27.50, 27.50)", formatBoneLoc(locs[0])) + self.assertEqual("(27.50, 27.50)", formatBoneLoc(locs[1])) + self.assertEqual("(27.50, 72.50)", formatBoneLoc(locs[2])) + self.assertEqual("(27.50, 72.50)", formatBoneLoc(locs[3])) + self.assertEqual("(72.50, 27.50)", formatBoneLoc(locs[4])) + self.assertEqual("(72.50, 27.50)", formatBoneLoc(locs[5])) + self.assertEqual("(72.50, 72.50)", formatBoneLoc(locs[6])) + self.assertEqual("(72.50, 72.50)", formatBoneLoc(locs[7])) FreeCAD.closeDocument("TestDressupDogbone") diff --git a/src/Mod/Path/PathTests/TestPathDressupHoldingTags.py b/src/Mod/Path/PathTests/TestPathDressupHoldingTags.py index b102659a06..b202430e5d 100644 --- a/src/Mod/Path/PathTests/TestPathDressupHoldingTags.py +++ b/src/Mod/Path/PathTests/TestPathDressupHoldingTags.py @@ -22,17 +22,13 @@ # * * # *************************************************************************** -import FreeCAD -import Path -import PathScripts +import PathTests.PathTestUtils as PathTestUtils import math -import unittest from FreeCAD import Vector -from PathScripts.PathDressupHoldingTags import * -from PathTests.PathTestUtils import PathTestBase +from PathScripts.PathDressupHoldingTags import Tag -class TestHoldingTags(PathTestBase): +class TestHoldingTags(PathTestUtils.PathTestBase): """Unit tests for the HoldingTags dressup.""" def test00(self): diff --git a/src/Mod/Path/PathTests/TestPathGeom.py b/src/Mod/Path/PathTests/TestPathGeom.py index 5900a097bb..f4882d4000 100644 --- a/src/Mod/Path/PathTests/TestPathGeom.py +++ b/src/Mod/Path/PathTests/TestPathGeom.py @@ -22,13 +22,10 @@ # * * # *************************************************************************** -import FreeCAD import Part import Path -import PathScripts import PathScripts.PathGeom as PathGeom import math -import unittest from FreeCAD import Vector from PathTests.PathTestUtils import PathTestBase @@ -238,10 +235,6 @@ class TestPathGeom(PathTestBase): self.assertLine(PathGeom.edgeForCmd(Path.Command('G1', {'X': 7, 'Y': 2, 'Z': 3}), spt), spt, Vector(7, 2, 3)) self.assertLine(PathGeom.edgeForCmd(Path.Command('G01', {'X': 1, 'Y': 3, 'Z': 5}), spt), spt, Vector(1, 3, 5)) - def test15(self): - """Verify proper feed rate for G1 commands is assigned.""" - pass - def test20(self): """Verify proper geometry for arcs in the XY-plane are created.""" p1 = Vector(0, -1, 2) @@ -369,7 +362,6 @@ class TestPathGeom(PathTestBase): e = PathGeom.arcToHelix(Part.Edge(Part.Arc(p11, p12, p13)), 2, -2) self.assertCurve(e, p1 + Vector(0,0,2), p2, p3 + Vector(0,0,-2)) - o = 10*math.sin(math.pi/4) p1 = Vector(10, -10, 1) p2 = Vector(10 - 10*math.sin(math.pi/4), -10*math.cos(math.pi/4), 1) p3 = Vector(0, 0, 1) @@ -431,8 +423,6 @@ class TestPathGeom(PathTestBase): o = 10*math.sin(math.pi/4) p12 = Vector(10 - o, -o, 2.5) p23 = Vector(10 - o, +o, 7.5) - pf = e[0].valueAt((e[0].FirstParameter + e[0].LastParameter)/2) - pl = e[1].valueAt((e[1].FirstParameter + e[1].LastParameter)/2) self.assertCurve(e[0], p1, p12, p2) self.assertCurve(e[1], p2, p23, p3) diff --git a/src/Mod/Path/PathTests/TestPathLog.py b/src/Mod/Path/PathTests/TestPathLog.py index f9b1c81bb5..5af2a4f7b2 100644 --- a/src/Mod/Path/PathTests/TestPathLog.py +++ b/src/Mod/Path/PathTests/TestPathLog.py @@ -35,11 +35,11 @@ class TestPathLog(unittest.TestCase): PathLog.untrackAllModules() def callerFile(self): - return PathLog._caller()[0] + return PathLog._caller()[0] # pylint: disable=protected-access def callerLine(self): - return PathLog._caller()[1] + return PathLog._caller()[1] # pylint: disable=protected-access def callerFunc(self): - return PathLog._caller()[2] + return PathLog._caller()[2] # pylint: disable=protected-access def test00(self): """Check for proper module extraction.""" diff --git a/src/Mod/Path/PathTests/TestPathOpTools.py b/src/Mod/Path/PathTests/TestPathOpTools.py index 1dbfb43552..7ee54417f9 100644 --- a/src/Mod/Path/PathTests/TestPathOpTools.py +++ b/src/Mod/Path/PathTests/TestPathOpTools.py @@ -24,7 +24,6 @@ import FreeCAD import Part -import Path import PathScripts.PathGeom as PathGeom import PathScripts.PathOpTools as PathOpTools import PathScripts.PathLog as PathLog @@ -78,7 +77,7 @@ class TestPathOpTools(PathTestUtils.PathTestBase): @classmethod def setUpClass(cls): - global doc + global doc # pylint: disable=global-statement doc = FreeCAD.openDocument(FreeCAD.getHomePath() + 'Mod/Path/PathTests/test_geomop.fcstd') @classmethod diff --git a/src/Mod/Path/PathTests/TestPathPost.py b/src/Mod/Path/PathTests/TestPathPost.py index 02ca02faf3..0e504aeced 100644 --- a/src/Mod/Path/PathTests/TestPathPost.py +++ b/src/Mod/Path/PathTests/TestPathPost.py @@ -33,6 +33,7 @@ import PathScripts.PathUtil import difflib import unittest +WriteDebugOutput = False class PathPostTestCases(unittest.TestCase): @@ -63,8 +64,8 @@ class PathPostTestCases(unittest.TestCase): refGCode = fp.read() # Use if this test fails in order to have a real good look at the changes - if False: - with open('tab.tmp', 'w') as fp: + if WriteDebugOutput: + with open('testLinuxCNC.tmp', 'w') as fp: fp.write(gcode) if gcode != refGCode: @@ -81,8 +82,8 @@ class PathPostTestCases(unittest.TestCase): refGCode = fp.read() # Use if this test fails in order to have a real good look at the changes - if False: - with open('tab.tmp', 'w') as fp: + if WriteDebugOutput: + with open('testLinuxCNCImplerial.tmp', 'w') as fp: fp.write(gcode) if gcode != refGCode: @@ -99,8 +100,8 @@ class PathPostTestCases(unittest.TestCase): refGCode = fp.read() # Use if this test fails in order to have a real good look at the changes - if False: - with open('tab.tmp', 'w') as fp: + if WriteDebugOutput: + with open('testCentroid.tmp', 'w') as fp: fp.write(gcode) if gcode != refGCode: diff --git a/src/Mod/Path/PathTests/TestPathSetupSheet.py b/src/Mod/Path/PathTests/TestPathSetupSheet.py index a92375561d..3bd7707978 100644 --- a/src/Mod/Path/PathTests/TestPathSetupSheet.py +++ b/src/Mod/Path/PathTests/TestPathSetupSheet.py @@ -23,7 +23,6 @@ # *************************************************************************** import FreeCAD -import Path import PathScripts.PathSetupSheet as PathSetupSheet import PathScripts.PathLog as PathLog import sys diff --git a/src/Mod/Path/PathTests/TestPathStock.py b/src/Mod/Path/PathTests/TestPathStock.py index 7e4762799f..d85b957c5f 100644 --- a/src/Mod/Path/PathTests/TestPathStock.py +++ b/src/Mod/Path/PathTests/TestPathStock.py @@ -23,8 +23,6 @@ # *************************************************************************** import FreeCAD -import Part -import Path import PathScripts.PathStock as PathStock from PathTests.PathTestUtils import PathTestBase diff --git a/src/Mod/Path/PathTests/TestPathTool.py b/src/Mod/Path/PathTests/TestPathTool.py index a3aa459fd0..85a1f2c82a 100644 --- a/src/Mod/Path/PathTests/TestPathTool.py +++ b/src/Mod/Path/PathTests/TestPathTool.py @@ -22,7 +22,6 @@ # * * # *************************************************************************** -import FreeCAD import Path from PathTests.PathTestUtils import PathTestBase diff --git a/src/Mod/Path/PathTests/TestPathTooltable.py b/src/Mod/Path/PathTests/TestPathTooltable.py index dbde438e09..9ac2b722c1 100644 --- a/src/Mod/Path/PathTests/TestPathTooltable.py +++ b/src/Mod/Path/PathTests/TestPathTooltable.py @@ -22,7 +22,6 @@ # * * # *************************************************************************** -import FreeCAD import Path from PathTests.PathTestUtils import PathTestBase diff --git a/src/Mod/Path/PathTests/TestPathUtil.py b/src/Mod/Path/PathTests/TestPathUtil.py index a2b996d5ff..20edcd276a 100644 --- a/src/Mod/Path/PathTests/TestPathUtil.py +++ b/src/Mod/Path/PathTests/TestPathUtil.py @@ -23,10 +23,7 @@ # *************************************************************************** import FreeCAD -import Part -import Path import PathScripts.PathUtil as PathUtil -import Sketcher import TestSketcherApp from PathTests.PathTestUtils import PathTestBase diff --git a/src/Mod/Path/utils/path-lint.sh b/src/Mod/Path/utils/path-lint.sh index 8b04133cbd..f0106ca82d 100755 --- a/src/Mod/Path/utils/path-lint.sh +++ b/src/Mod/Path/utils/path-lint.sh @@ -57,6 +57,7 @@ EXTERNAL_MODULES+=' PySide' EXTERNAL_MODULES+=' PySide.QtCore' EXTERNAL_MODULES+=' PySide.QtGui' EXTERNAL_MODULES+=' TechDraw' +EXTERNAL_MODULES+=' TestSketcherApp' EXTERNAL_MODULES+=' area' EXTERNAL_MODULES+=' importlib' EXTERNAL_MODULES+=' ocl' @@ -79,6 +80,7 @@ if [ -z "$(which pylint3)" ]; then exit 1 fi -#pylint3 ${ARGS} PathScripts/ PathTests/ -pylint3 ${ARGS} PathScripts/ +pylint3 ${ARGS} PathScripts/ PathTests/ +#pylint3 ${ARGS} PathScripts/ +#pylint3 ${ARGS} PathTests/