Draft: update snake_case for unit tests
Also fix the name of certain functions. Do not import `DraftFillet` any more as it's just kept for compatibility purposes. Do not test OCA nor AirfoilDAT as it's very improbable that these formats will gain more support any time soon.
This commit is contained in:
@@ -105,8 +105,8 @@ from drafttests.test_modification import DraftModification as DraftTest03
|
||||
from drafttests.test_svg import DraftSVG as DraftTest04
|
||||
from drafttests.test_dxf import DraftDXF as DraftTest05
|
||||
from drafttests.test_dwg import DraftDWG as DraftTest06
|
||||
from drafttests.test_oca import DraftOCA as DraftTest07
|
||||
from drafttests.test_airfoildat import DraftAirfoilDAT as DraftTest08
|
||||
# from drafttests.test_oca import DraftOCA as DraftTest07
|
||||
# from drafttests.test_airfoildat import DraftAirfoilDAT as DraftTest08
|
||||
|
||||
# Use the modules so that code checkers don't complain (flake8)
|
||||
True if DraftTest01 else False
|
||||
@@ -115,5 +115,5 @@ True if DraftTest03 else False
|
||||
True if DraftTest04 else False
|
||||
True if DraftTest05 else False
|
||||
True if DraftTest06 else False
|
||||
True if DraftTest07 else False
|
||||
True if DraftTest08 else False
|
||||
# True if DraftTest07 else False
|
||||
# True if DraftTest08 else False
|
||||
|
||||
@@ -27,13 +27,13 @@ import traceback
|
||||
from draftutils.messages import _msg
|
||||
|
||||
|
||||
def _draw_header():
|
||||
def draw_header():
|
||||
"""Draw a header for the tests."""
|
||||
_msg("")
|
||||
_msg(78*"-")
|
||||
|
||||
|
||||
def _import_test(module):
|
||||
def import_test(module):
|
||||
"""Try importing a module."""
|
||||
_msg(" Try importing '{}'".format(module))
|
||||
try:
|
||||
@@ -45,7 +45,7 @@ def _import_test(module):
|
||||
return imported
|
||||
|
||||
|
||||
def _no_gui(module):
|
||||
def no_gui(module):
|
||||
"""Print a message that there is no user interface."""
|
||||
_msg(" #-----------------------------------------------------#\n"
|
||||
" # No GUI; cannot test for '{}'\n"
|
||||
@@ -53,7 +53,7 @@ def _no_gui(module):
|
||||
" Automatic PASS".format(module))
|
||||
|
||||
|
||||
def _no_test():
|
||||
def no_test():
|
||||
"""Print a message that the test is not currently implemented."""
|
||||
_msg(" #-----------------------------------------------------#\n"
|
||||
" # This test is not implemented currently\n"
|
||||
@@ -61,11 +61,11 @@ def _no_test():
|
||||
" Automatic PASS")
|
||||
|
||||
|
||||
def _fake_function(p1=None, p2=None, p3=None, p4=None, p5=None):
|
||||
def fake_function(p1=None, p2=None, p3=None, p4=None, p5=None):
|
||||
"""Print a message for a test that doesn't actually exist."""
|
||||
_msg(" Arguments to placeholder function")
|
||||
_msg(" p1={0}; p2={1}".format(p1, p2))
|
||||
_msg(" p3={0}; p4={1}".format(p3, p4))
|
||||
_msg(" p5={}".format(p5))
|
||||
_no_test()
|
||||
no_test()
|
||||
return True
|
||||
|
||||
@@ -40,7 +40,7 @@ class DraftAirfoilDAT(unittest.TestCase):
|
||||
This is executed before every test, so we create a document
|
||||
to hold the objects.
|
||||
"""
|
||||
aux._draw_header()
|
||||
aux.draw_header()
|
||||
self.doc_name = self.__class__.__name__
|
||||
if App.ActiveDocument:
|
||||
if App.ActiveDocument.Name != self.doc_name:
|
||||
@@ -62,8 +62,8 @@ class DraftAirfoilDAT(unittest.TestCase):
|
||||
_msg(" file={}".format(in_file))
|
||||
_msg(" exists={}".format(os.path.exists(in_file)))
|
||||
|
||||
Draft.import_AirfoilDAT = aux._fake_function
|
||||
obj = Draft.import_AirfoilDAT(in_file)
|
||||
Draft.import_airfoildat = aux.fake_function
|
||||
obj = Draft.import_airfoildat(in_file)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_export_airfoildat(self):
|
||||
@@ -76,8 +76,8 @@ class DraftAirfoilDAT(unittest.TestCase):
|
||||
_msg(" file={}".format(out_file))
|
||||
_msg(" exists={}".format(os.path.exists(out_file)))
|
||||
|
||||
Draft.export_importAirfoilDAT = aux._fake_function
|
||||
obj = Draft.export_importAirfoilDAT(out_file)
|
||||
Draft.export_airfoildat = aux.fake_function
|
||||
obj = Draft.export_airfoildat(out_file)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def tearDown(self):
|
||||
|
||||
@@ -25,9 +25,11 @@
|
||||
|
||||
import unittest
|
||||
import math
|
||||
|
||||
import FreeCAD as App
|
||||
import Draft
|
||||
import drafttests.auxiliary as aux
|
||||
|
||||
from FreeCAD import Vector
|
||||
from draftutils.messages import _msg
|
||||
|
||||
@@ -41,7 +43,7 @@ class DraftCreation(unittest.TestCase):
|
||||
This is executed before every test, so we create a document
|
||||
to hold the objects.
|
||||
"""
|
||||
aux._draw_header()
|
||||
aux.draw_header()
|
||||
doc_name = self.__class__.__name__
|
||||
if App.ActiveDocument:
|
||||
if App.ActiveDocument.Name != doc_name:
|
||||
@@ -59,7 +61,7 @@ class DraftCreation(unittest.TestCase):
|
||||
a = Vector(0, 0, 0)
|
||||
b = Vector(2, 0, 0)
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
obj = Draft.makeLine(a, b)
|
||||
obj = Draft.make_line(a, b)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_polyline(self):
|
||||
@@ -71,7 +73,7 @@ class DraftCreation(unittest.TestCase):
|
||||
c = Vector(2, 2, 0)
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
_msg(" c={}".format(c))
|
||||
obj = Draft.makeWire([a, b, c])
|
||||
obj = Draft.make_wire([a, b, c])
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_fillet(self):
|
||||
@@ -84,8 +86,8 @@ class DraftCreation(unittest.TestCase):
|
||||
_msg(" Lines")
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
_msg(" b={0}, c={1}".format(b, c))
|
||||
L1 = Draft.makeLine(a, b)
|
||||
L2 = Draft.makeLine(b, c)
|
||||
L1 = Draft.make_line(a, b)
|
||||
L2 = Draft.make_line(b, c)
|
||||
self.doc.recompute()
|
||||
|
||||
radius = 4
|
||||
@@ -100,7 +102,7 @@ class DraftCreation(unittest.TestCase):
|
||||
_msg(" Test '{}'".format(operation))
|
||||
radius = 3
|
||||
_msg(" radius={}".format(radius))
|
||||
obj = Draft.makeCircle(radius)
|
||||
obj = Draft.make_circle(radius)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_arc(self):
|
||||
@@ -113,8 +115,8 @@ class DraftCreation(unittest.TestCase):
|
||||
_msg(" radius={}".format(radius))
|
||||
_msg(" startangle={0}, endangle={1}".format(start_angle,
|
||||
end_angle))
|
||||
obj = Draft.makeCircle(radius,
|
||||
startangle=start_angle, endangle=end_angle)
|
||||
obj = Draft.make_circle(radius,
|
||||
startangle=start_angle, endangle=end_angle)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_arc_3points(self):
|
||||
@@ -137,7 +139,7 @@ class DraftCreation(unittest.TestCase):
|
||||
a = 5
|
||||
b = 3
|
||||
_msg(" major_axis={0}, minor_axis={1}".format(a, b))
|
||||
obj = Draft.makeEllipse(a, b)
|
||||
obj = Draft.make_ellipse(a, b)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_polygon(self):
|
||||
@@ -147,7 +149,7 @@ class DraftCreation(unittest.TestCase):
|
||||
n_faces = 6
|
||||
radius = 5
|
||||
_msg(" n_faces={0}, radius={1}".format(n_faces, radius))
|
||||
obj = Draft.makePolygon(n_faces, radius)
|
||||
obj = Draft.make_polygon(n_faces, radius)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_rectangle(self):
|
||||
@@ -157,7 +159,7 @@ class DraftCreation(unittest.TestCase):
|
||||
length = 5
|
||||
width = 2
|
||||
_msg(" length={0}, width={1}".format(length, width))
|
||||
obj = Draft.makeRectangle(length, width)
|
||||
obj = Draft.make_rectangle(length, width)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_text(self):
|
||||
@@ -166,7 +168,7 @@ class DraftCreation(unittest.TestCase):
|
||||
_msg(" Test '{}'".format(operation))
|
||||
text = "Testing testing"
|
||||
_msg(" text='{}'".format(text))
|
||||
obj = Draft.makeText(text)
|
||||
obj = Draft.make_text(text)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_dimension_linear(self):
|
||||
@@ -179,7 +181,7 @@ class DraftCreation(unittest.TestCase):
|
||||
c = Vector(4, -1, 0)
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
_msg(" c={}".format(c))
|
||||
obj = Draft.makeDimension(a, b, c)
|
||||
obj = Draft.make_dimension(a, b, c)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_dimension_radial(self):
|
||||
@@ -192,14 +194,14 @@ class DraftCreation(unittest.TestCase):
|
||||
_msg(" radius={}".format(radius))
|
||||
_msg(" startangle={0}, endangle={1}".format(start_angle,
|
||||
end_angle))
|
||||
circ = Draft.makeCircle(radius,
|
||||
startangle=start_angle, endangle=end_angle)
|
||||
circ = Draft.make_circle(radius,
|
||||
startangle=start_angle, endangle=end_angle)
|
||||
self.doc.recompute()
|
||||
|
||||
obj1 = Draft.makeDimension(circ, 0,
|
||||
p3="radius", p4=Vector(1, 1, 0))
|
||||
obj2 = Draft.makeDimension(circ, 0,
|
||||
p3="diameter", p4=Vector(3, 1, 0))
|
||||
obj1 = Draft.make_dimension(circ, 0,
|
||||
p3="radius", p4=Vector(1, 1, 0))
|
||||
obj2 = Draft.make_dimension(circ, 0,
|
||||
p3="diameter", p4=Vector(3, 1, 0))
|
||||
self.assertTrue(obj1 and obj2, "'{}' failed".format(operation))
|
||||
|
||||
def test_dimension_angular(self):
|
||||
@@ -215,7 +217,7 @@ class DraftCreation(unittest.TestCase):
|
||||
_msg(" angle1={0}, angle2={1}".format(math.degrees(angle1),
|
||||
math.degrees(angle2)))
|
||||
_msg(" point={}".format(p3))
|
||||
obj = Draft.makeAngularDimension(center, [angle1, angle2], p3)
|
||||
obj = Draft.make_angular_dimension(center, [angle1, angle2], p3)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_bspline(self):
|
||||
@@ -227,7 +229,7 @@ class DraftCreation(unittest.TestCase):
|
||||
c = Vector(2, 2, 0)
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
_msg(" c={}".format(c))
|
||||
obj = Draft.makeBSpline([a, b, c])
|
||||
obj = Draft.make_bspline([a, b, c])
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_point(self):
|
||||
@@ -236,7 +238,7 @@ class DraftCreation(unittest.TestCase):
|
||||
_msg(" Test '{}'".format(operation))
|
||||
p = Vector(5, 3, 2)
|
||||
_msg(" p.x={0}, p.y={1}, p.z={2}".format(p.x, p.y, p.z))
|
||||
obj = Draft.makePoint(p.x, p.y, p.z)
|
||||
obj = Draft.make_point(p.x, p.y, p.z)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_shapestring(self):
|
||||
@@ -248,9 +250,9 @@ class DraftCreation(unittest.TestCase):
|
||||
# TODO: find a reliable way to always get a font file here
|
||||
font = None
|
||||
_msg(" text='{0}', font='{1}'".format(text, font))
|
||||
Draft.makeShapeString = aux._fake_function
|
||||
obj = Draft.makeShapeString("Text", font)
|
||||
# Draft.makeShapeString("Text", FontFile="")
|
||||
Draft.make_shapestring = aux.fake_function
|
||||
obj = Draft.make_shapestring("Text", font)
|
||||
# Draft.make_shapestring("Text", FontFile="")
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_facebinder(self):
|
||||
@@ -276,7 +278,7 @@ class DraftCreation(unittest.TestCase):
|
||||
elements = selection_set[0][1]
|
||||
_msg(" object='{0}' ({1})".format(box.Shape.ShapeType, box.TypeId))
|
||||
_msg(" sub-elements={}".format(elements))
|
||||
obj = Draft.makeFacebinder(selection_set)
|
||||
obj = Draft.make_facebinder(selection_set)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_cubicbezcurve(self):
|
||||
@@ -289,7 +291,7 @@ class DraftCreation(unittest.TestCase):
|
||||
d = Vector(9, 0, 0)
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
_msg(" c={0}, d={1}".format(c, d))
|
||||
obj = Draft.makeBezCurve([a, b, c, d], degree=3)
|
||||
obj = Draft.make_bezcurve([a, b, c, d], degree=3)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_bezcurve(self):
|
||||
@@ -305,7 +307,7 @@ class DraftCreation(unittest.TestCase):
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
_msg(" c={0}, d={1}".format(c, d))
|
||||
_msg(" e={0}, f={1}".format(e, f))
|
||||
obj = Draft.makeBezCurve([a, b, c, d, e, f])
|
||||
obj = Draft.make_bezcurve([a, b, c, d, e, f])
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_label(self):
|
||||
@@ -319,9 +321,9 @@ class DraftCreation(unittest.TestCase):
|
||||
_msg(" target_point={0}, "
|
||||
"distance={1}".format(target_point, distance))
|
||||
_msg(" placement={}".format(placement))
|
||||
obj = Draft.makeLabel(targetpoint=target_point,
|
||||
distance=distance,
|
||||
placement=placement)
|
||||
obj = Draft.make_label(targetpoint=target_point,
|
||||
distance=distance,
|
||||
placement=placement)
|
||||
self.doc.recompute()
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class DraftDWG(unittest.TestCase):
|
||||
This is executed before every test, so we create a document
|
||||
to hold the objects.
|
||||
"""
|
||||
aux._draw_header()
|
||||
aux.draw_header()
|
||||
self.doc_name = self.__class__.__name__
|
||||
if App.ActiveDocument:
|
||||
if App.ActiveDocument.Name != self.doc_name:
|
||||
@@ -62,8 +62,8 @@ class DraftDWG(unittest.TestCase):
|
||||
_msg(" file={}".format(in_file))
|
||||
_msg(" exists={}".format(os.path.exists(in_file)))
|
||||
|
||||
Draft.import_DWG = aux._fake_function
|
||||
obj = Draft.import_DWG(in_file)
|
||||
Draft.import_dwg = aux.fake_function
|
||||
obj = Draft.import_dwg(in_file)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_export_dwg(self):
|
||||
@@ -76,8 +76,8 @@ class DraftDWG(unittest.TestCase):
|
||||
_msg(" file={}".format(out_file))
|
||||
_msg(" exists={}".format(os.path.exists(out_file)))
|
||||
|
||||
Draft.export_DWG = aux._fake_function
|
||||
obj = Draft.export_DWG(out_file)
|
||||
Draft.export_dwg = aux.fake_function
|
||||
obj = Draft.export_dwg(out_file)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def tearDown(self):
|
||||
|
||||
@@ -40,7 +40,7 @@ class DraftDXF(unittest.TestCase):
|
||||
This is executed before every test, so we create a document
|
||||
to hold the objects.
|
||||
"""
|
||||
aux._draw_header()
|
||||
aux.draw_header()
|
||||
self.doc_name = self.__class__.__name__
|
||||
if App.ActiveDocument:
|
||||
if App.ActiveDocument.Name != self.doc_name:
|
||||
@@ -62,8 +62,8 @@ class DraftDXF(unittest.TestCase):
|
||||
_msg(" file={}".format(in_file))
|
||||
_msg(" exists={}".format(os.path.exists(in_file)))
|
||||
|
||||
Draft.import_DXF = aux._fake_function
|
||||
obj = Draft.import_DXF(in_file)
|
||||
Draft.import_dxf = aux.fake_function
|
||||
obj = Draft.import_dxf(in_file)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_export_dxf(self):
|
||||
@@ -76,8 +76,8 @@ class DraftDXF(unittest.TestCase):
|
||||
_msg(" file={}".format(out_file))
|
||||
_msg(" exists={}".format(os.path.exists(out_file)))
|
||||
|
||||
Draft.export_DXF = aux._fake_function
|
||||
obj = Draft.export_DXF(out_file)
|
||||
Draft.export_dxf = aux.fake_function
|
||||
obj = Draft.export_dxf(out_file)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def tearDown(self):
|
||||
|
||||
@@ -33,28 +33,28 @@ class DraftImport(unittest.TestCase):
|
||||
# No document is needed to test 'import Draft' or other modules
|
||||
# thus 'setUp' just draws a line, and 'tearDown' isn't defined.
|
||||
def setUp(self):
|
||||
aux._draw_header()
|
||||
aux.draw_header()
|
||||
|
||||
def test_import_draft(self):
|
||||
"""Import the Draft module."""
|
||||
module = "Draft"
|
||||
imported = aux._import_test(module)
|
||||
imported = aux.import_test(module)
|
||||
self.assertTrue(imported, "Problem importing '{}'".format(module))
|
||||
|
||||
def test_import_draft_geomutils(self):
|
||||
"""Import Draft geometrical utilities."""
|
||||
module = "DraftGeomUtils"
|
||||
imported = aux._import_test(module)
|
||||
imported = aux.import_test(module)
|
||||
self.assertTrue(imported, "Problem importing '{}'".format(module))
|
||||
|
||||
def test_import_draft_vecutils(self):
|
||||
"""Import Draft vector utilities."""
|
||||
module = "DraftVecUtils"
|
||||
imported = aux._import_test(module)
|
||||
imported = aux.import_test(module)
|
||||
self.assertTrue(imported, "Problem importing '{}'".format(module))
|
||||
|
||||
def test_import_draft_svg(self):
|
||||
"""Import Draft SVG utilities."""
|
||||
module = "getSVG"
|
||||
imported = aux._import_test(module)
|
||||
imported = aux.import_test(module)
|
||||
self.assertTrue(imported, "Problem importing '{}'".format(module))
|
||||
|
||||
@@ -33,28 +33,28 @@ class DraftGuiImport(unittest.TestCase):
|
||||
# No document is needed to test 'import DraftGui' or other modules
|
||||
# thus 'setUp' just draws a line, and 'tearDown' isn't defined.
|
||||
def setUp(self):
|
||||
aux._draw_header()
|
||||
aux.draw_header()
|
||||
|
||||
def test_import_gui_draftgui(self):
|
||||
"""Import Draft TaskView GUI tools."""
|
||||
module = "DraftGui"
|
||||
imported = aux._import_test(module)
|
||||
imported = aux.import_test(module)
|
||||
self.assertTrue(imported, "Problem importing '{}'".format(module))
|
||||
|
||||
def test_import_gui_draft_snap(self):
|
||||
"""Import Draft snapping."""
|
||||
module = "draftguitools.gui_snapper"
|
||||
imported = aux._import_test(module)
|
||||
imported = aux.import_test(module)
|
||||
self.assertTrue(imported, "Problem importing '{}'".format(module))
|
||||
|
||||
def test_import_gui_draft_tools(self):
|
||||
"""Import Draft graphical commands."""
|
||||
module = "DraftTools"
|
||||
imported = aux._import_test(module)
|
||||
imported = aux.import_test(module)
|
||||
self.assertTrue(imported, "Problem importing '{}'".format(module))
|
||||
|
||||
def test_import_gui_draft_trackers(self):
|
||||
"""Import Draft tracker utilities."""
|
||||
module = "draftguitools.gui_trackers"
|
||||
imported = aux._import_test(module)
|
||||
imported = aux.import_test(module)
|
||||
self.assertTrue(imported, "Problem importing '{}'".format(module))
|
||||
|
||||
@@ -33,34 +33,28 @@ class DraftImportTools(unittest.TestCase):
|
||||
# No document is needed to test 'import' of other modules
|
||||
# thus 'setUp' just draws a line, and 'tearDown' isn't defined.
|
||||
def setUp(self):
|
||||
aux._draw_header()
|
||||
aux.draw_header()
|
||||
|
||||
def test_import_gui_draftedit(self):
|
||||
"""Import Draft Edit."""
|
||||
module = "draftguitools.gui_edit"
|
||||
imported = aux._import_test(module)
|
||||
self.assertTrue(imported, "Problem importing '{}'".format(module))
|
||||
|
||||
def test_import_gui_draftfillet(self):
|
||||
"""Import Draft Fillet."""
|
||||
module = "DraftFillet"
|
||||
imported = aux._import_test(module)
|
||||
imported = aux.import_test(module)
|
||||
self.assertTrue(imported, "Problem importing '{}'".format(module))
|
||||
|
||||
def test_import_gui_draftlayer(self):
|
||||
"""Import Draft Layer."""
|
||||
module = "DraftLayer"
|
||||
imported = aux._import_test(module)
|
||||
imported = aux.import_test(module)
|
||||
self.assertTrue(imported, "Problem importing '{}'".format(module))
|
||||
|
||||
def test_import_gui_draftplane(self):
|
||||
"""Import Draft SelectPlane."""
|
||||
module = "draftguitools.gui_selectplane"
|
||||
imported = aux._import_test(module)
|
||||
imported = aux.import_test(module)
|
||||
self.assertTrue(imported, "Problem importing '{}'".format(module))
|
||||
|
||||
def test_import_gui_workingplane(self):
|
||||
"""Import Draft WorkingPlane."""
|
||||
module = "WorkingPlane"
|
||||
imported = aux._import_test(module)
|
||||
imported = aux.import_test(module)
|
||||
self.assertTrue(imported, "Problem importing '{}'".format(module))
|
||||
|
||||
@@ -40,7 +40,7 @@ class DraftModification(unittest.TestCase):
|
||||
This is executed before every test, so we create a document
|
||||
to hold the objects.
|
||||
"""
|
||||
aux._draw_header()
|
||||
aux.draw_header()
|
||||
self.doc_name = self.__class__.__name__
|
||||
if App.ActiveDocument:
|
||||
if App.ActiveDocument.Name != self.doc_name:
|
||||
@@ -59,7 +59,7 @@ class DraftModification(unittest.TestCase):
|
||||
b = Vector(2, 2, 0)
|
||||
_msg(" Line")
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
obj = Draft.makeLine(a, b)
|
||||
obj = Draft.make_line(a, b)
|
||||
|
||||
c = Vector(3, 1, 0)
|
||||
_msg(" Translation vector")
|
||||
@@ -76,7 +76,7 @@ class DraftModification(unittest.TestCase):
|
||||
b = Vector(2, 3, 0)
|
||||
_msg(" Line")
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
line = Draft.makeLine(a, b)
|
||||
line = Draft.make_line(a, b)
|
||||
|
||||
c = Vector(2, 2, 0)
|
||||
_msg(" Translation vector (copy)")
|
||||
@@ -92,7 +92,7 @@ class DraftModification(unittest.TestCase):
|
||||
b = Vector(3, 1, 0)
|
||||
_msg(" Line")
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
obj = Draft.makeLine(a, b)
|
||||
obj = Draft.make_line(a, b)
|
||||
App.ActiveDocument.recompute()
|
||||
|
||||
c = Vector(-1, 1, 0)
|
||||
@@ -113,7 +113,7 @@ class DraftModification(unittest.TestCase):
|
||||
_msg(" Wire")
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
_msg(" c={0}".format(c))
|
||||
wire = Draft.makeWire([a, b, c])
|
||||
wire = Draft.make_wire([a, b, c])
|
||||
App.ActiveDocument.recompute()
|
||||
|
||||
offset = Vector(-1, 1, 0)
|
||||
@@ -130,7 +130,7 @@ class DraftModification(unittest.TestCase):
|
||||
width = 2
|
||||
_msg(" Rectangle")
|
||||
_msg(" length={0}, width={1}".format(length, width))
|
||||
rect = Draft.makeRectangle(length, width)
|
||||
rect = Draft.make_rectangle(length, width)
|
||||
App.ActiveDocument.recompute()
|
||||
|
||||
offset = Vector(-1, -1, 0)
|
||||
@@ -148,16 +148,16 @@ class DraftModification(unittest.TestCase):
|
||||
|
||||
_msg(" Line")
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
line = Draft.makeLine(a, b)
|
||||
line = Draft.make_line(a, b)
|
||||
|
||||
c = Vector(2, 2, 0)
|
||||
d = Vector(4, 2, 0)
|
||||
_msg(" Line 2")
|
||||
_msg(" c={0}, d={1}".format(c, d))
|
||||
line2 = Draft.makeLine(c, d)
|
||||
line2 = Draft.make_line(c, d)
|
||||
App.ActiveDocument.recompute()
|
||||
|
||||
Draft.trim_objects = aux._fake_function
|
||||
Draft.trim_objects = aux.fake_function
|
||||
obj = Draft.trim_objects(line, line2)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
@@ -169,16 +169,16 @@ class DraftModification(unittest.TestCase):
|
||||
b = Vector(1, 1, 0)
|
||||
_msg(" Line")
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
line = Draft.makeLine(a, b)
|
||||
line = Draft.make_line(a, b)
|
||||
|
||||
c = Vector(2, 2, 0)
|
||||
d = Vector(4, 2, 0)
|
||||
_msg(" Line 2")
|
||||
_msg(" c={0}, d={1}".format(c, d))
|
||||
line2 = Draft.makeLine(c, d)
|
||||
line2 = Draft.make_line(c, d)
|
||||
App.ActiveDocument.recompute()
|
||||
|
||||
Draft.extrude = aux._fake_function
|
||||
Draft.extrude = aux.fake_function
|
||||
obj = Draft.extrude(line, line2)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
@@ -193,11 +193,11 @@ class DraftModification(unittest.TestCase):
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
_msg(" Line 2")
|
||||
_msg(" b={0}, c={1}".format(b, c))
|
||||
line_1 = Draft.makeLine(a, b)
|
||||
line_2 = Draft.makeLine(b, c)
|
||||
line_1 = Draft.make_line(a, b)
|
||||
line_2 = Draft.make_line(b, c)
|
||||
|
||||
# obj = Draft.joinWires([line_1, line_2]) # Multiple wires
|
||||
obj = Draft.joinTwoWires(line_1, line_2)
|
||||
# obj = Draft.join_wires([line_1, line_2]) # Multiple wires
|
||||
obj = Draft.join_two_wires(line_1, line_2)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_split(self):
|
||||
@@ -211,7 +211,7 @@ class DraftModification(unittest.TestCase):
|
||||
_msg(" Wire")
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
_msg(" c={0}, d={1}".format(c, d))
|
||||
wire = Draft.makeWire([a, b, c, d])
|
||||
wire = Draft.make_wire([a, b, c, d])
|
||||
|
||||
index = 1
|
||||
_msg(" Split at")
|
||||
@@ -234,8 +234,8 @@ class DraftModification(unittest.TestCase):
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
_msg(" Line 2")
|
||||
_msg(" b={0}, c={1}".format(b, c))
|
||||
line_1 = Draft.makeLine(a, b)
|
||||
line_2 = Draft.makeLine(b, c)
|
||||
line_1 = Draft.make_line(a, b)
|
||||
line_2 = Draft.make_line(b, c)
|
||||
App.ActiveDocument.recompute()
|
||||
|
||||
obj = Draft.upgrade([line_1, line_2], delete=True)
|
||||
@@ -274,7 +274,7 @@ class DraftModification(unittest.TestCase):
|
||||
_msg(" Closed wire")
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
_msg(" c={0}, a={1}".format(c, a))
|
||||
wire = Draft.makeWire([a, b, c, a])
|
||||
wire = Draft.make_wire([a, b, c, a])
|
||||
App.ActiveDocument.recompute()
|
||||
|
||||
obj = Draft.downgrade(wire, delete=True)
|
||||
@@ -313,14 +313,14 @@ class DraftModification(unittest.TestCase):
|
||||
_msg(" Wire")
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
_msg(" c={}".format(c))
|
||||
wire = Draft.makeWire([a, b, c])
|
||||
wire = Draft.make_wire([a, b, c])
|
||||
|
||||
obj = Draft.makeBSpline(wire.Points)
|
||||
obj = Draft.make_bspline(wire.Points)
|
||||
App.ActiveDocument.recompute()
|
||||
_msg(" 1: Result '{0}' ({1})".format(obj.Proxy.Type, obj.TypeId))
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
obj2 = Draft.makeWire(obj.Points)
|
||||
obj2 = Draft.make_wire(obj.Points)
|
||||
_msg(" 2: Result '{0}' ({1})".format(obj2.Proxy.Type, obj2.TypeId))
|
||||
self.assertTrue(obj2, "'{}' failed".format(operation))
|
||||
|
||||
@@ -340,7 +340,7 @@ class DraftModification(unittest.TestCase):
|
||||
direction = Vector(0, 0, 1)
|
||||
_msg(" Projection 2D view")
|
||||
_msg(" direction={}".format(direction))
|
||||
obj = Draft.makeShape2DView(prism, direction)
|
||||
obj = Draft.make_shape2dview(prism, direction)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_draft_to_sketch(self):
|
||||
@@ -353,10 +353,10 @@ class DraftModification(unittest.TestCase):
|
||||
_msg(" Wire")
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
_msg(" c={}".format(c))
|
||||
wire = Draft.makeWire([a, b, c])
|
||||
wire = Draft.make_wire([a, b, c])
|
||||
App.ActiveDocument.recompute()
|
||||
|
||||
obj = Draft.makeSketch(wire, autoconstraints=True)
|
||||
obj = Draft.make_sketch(wire, autoconstraints=True)
|
||||
App.ActiveDocument.recompute()
|
||||
_msg(" 1: Result '{0}' ({1})".format(obj.Shape.ShapeType,
|
||||
obj.TypeId))
|
||||
@@ -376,7 +376,7 @@ class DraftModification(unittest.TestCase):
|
||||
width = 2
|
||||
_msg(" Rectangle")
|
||||
_msg(" length={0}, width={1}".format(length, width))
|
||||
rect = Draft.makeRectangle(length, width)
|
||||
rect = Draft.make_rectangle(length, width)
|
||||
App.ActiveDocument.recompute()
|
||||
|
||||
dir_x = Vector(5, 0, 0)
|
||||
@@ -400,7 +400,7 @@ class DraftModification(unittest.TestCase):
|
||||
width = 2
|
||||
_msg(" Rectangle")
|
||||
_msg(" length={0}, width={1}".format(length, width))
|
||||
rect = Draft.makeRectangle(length, width)
|
||||
rect = Draft.make_rectangle(length, width)
|
||||
App.ActiveDocument.recompute()
|
||||
|
||||
center = Vector(-4, 0, 0)
|
||||
@@ -421,7 +421,7 @@ class DraftModification(unittest.TestCase):
|
||||
width = 2
|
||||
_msg(" Rectangle")
|
||||
_msg(" length={0}, width={1}".format(length, width))
|
||||
rect = Draft.makeRectangle(length, width)
|
||||
rect = Draft.make_rectangle(length, width)
|
||||
App.ActiveDocument.recompute()
|
||||
|
||||
rad_distance = 10
|
||||
@@ -453,13 +453,13 @@ class DraftModification(unittest.TestCase):
|
||||
_msg(" Wire")
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
_msg(" c={0}, d={1}".format(c, d))
|
||||
wire = Draft.makeWire([a, b, c, d])
|
||||
wire = Draft.make_wire([a, b, c, d])
|
||||
|
||||
n_faces = 3
|
||||
radius = 1
|
||||
_msg(" Polygon")
|
||||
_msg(" n_faces={0}, radius={1}".format(n_faces, radius))
|
||||
poly = Draft.makePolygon(n_faces, radius)
|
||||
poly = Draft.make_polygon(n_faces, radius)
|
||||
|
||||
number = 4
|
||||
translation = Vector(0, 1, 0)
|
||||
@@ -481,10 +481,10 @@ class DraftModification(unittest.TestCase):
|
||||
_msg(" Points")
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
_msg(" c={0}, d={1}".format(c, d))
|
||||
points = [Draft.makePoint(a),
|
||||
Draft.makePoint(b),
|
||||
Draft.makePoint(c),
|
||||
Draft.makePoint(d)]
|
||||
points = [Draft.make_point(a),
|
||||
Draft.make_point(b),
|
||||
Draft.make_point(c),
|
||||
Draft.make_point(d)]
|
||||
|
||||
_msg(" Upgrade")
|
||||
add, delete = Draft.upgrade(points)
|
||||
@@ -494,7 +494,7 @@ class DraftModification(unittest.TestCase):
|
||||
radius = 1
|
||||
_msg(" Polygon")
|
||||
_msg(" n_faces={0}, radius={1}".format(n_faces, radius))
|
||||
poly = Draft.makePolygon(n_faces, radius)
|
||||
poly = Draft.make_polygon(n_faces, radius)
|
||||
|
||||
_msg(" Point Array")
|
||||
obj = Draft.makePointArray(poly, compound)
|
||||
@@ -511,7 +511,7 @@ class DraftModification(unittest.TestCase):
|
||||
App.ActiveDocument.recompute()
|
||||
_msg(" object: '{0}' ({1})".format(box.Shape.ShapeType, box.TypeId))
|
||||
|
||||
obj = Draft.clone(box)
|
||||
obj = Draft.make_clone(box)
|
||||
_msg(" clone: '{0}' ({1})".format(obj.Proxy.Type, obj.TypeId))
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
self.assertTrue(obj.hasExtension("Part::AttachExtension"),
|
||||
@@ -533,8 +533,8 @@ class DraftModification(unittest.TestCase):
|
||||
_msg(" placement={}".format(prism.Placement))
|
||||
|
||||
svg_template = 'Mod/Drawing/Templates/A3_Landscape.svg'
|
||||
template = Draft.getParam("template",
|
||||
App.getResourceDir() + svg_template)
|
||||
template = Draft.get_param("template",
|
||||
App.getResourceDir() + svg_template)
|
||||
page = App.ActiveDocument.addObject('Drawing::FeaturePage')
|
||||
page.Template = template
|
||||
_msg(" Drawing view")
|
||||
@@ -551,7 +551,7 @@ class DraftModification(unittest.TestCase):
|
||||
width = 2
|
||||
_msg(" Rectangle")
|
||||
_msg(" length={0}, width={1}".format(length, width))
|
||||
rect = Draft.makeRectangle(length, width)
|
||||
rect = Draft.make_rectangle(length, width)
|
||||
# App.ActiveDocument.recompute()
|
||||
|
||||
p1 = Vector(6, -2, 0)
|
||||
@@ -571,10 +571,10 @@ class DraftModification(unittest.TestCase):
|
||||
b = Vector(1, 1, 0)
|
||||
_msg(" Line")
|
||||
_msg(" a={0}, b={1}".format(a, b))
|
||||
line = Draft.makeLine(a, b)
|
||||
line = Draft.make_line(a, b)
|
||||
direction = Vector(4, 1, 0)
|
||||
|
||||
Draft.stretch = aux._fake_function
|
||||
Draft.stretch = aux.fake_function
|
||||
obj = Draft.stretch(line, direction)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class DraftOCA(unittest.TestCase):
|
||||
This is executed before every test, so we create a document
|
||||
to hold the objects.
|
||||
"""
|
||||
aux._draw_header()
|
||||
aux.draw_header()
|
||||
self.doc_name = self.__class__.__name__
|
||||
if App.ActiveDocument:
|
||||
if App.ActiveDocument.Name != self.doc_name:
|
||||
@@ -62,8 +62,8 @@ class DraftOCA(unittest.TestCase):
|
||||
_msg(" file={}".format(in_file))
|
||||
_msg(" exists={}".format(os.path.exists(in_file)))
|
||||
|
||||
Draft.import_OCA = aux._fake_function
|
||||
obj = Draft.import_OCA(in_file)
|
||||
Draft.import_oca = aux.fake_function
|
||||
obj = Draft.import_oca(in_file)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_export_oca(self):
|
||||
@@ -76,8 +76,8 @@ class DraftOCA(unittest.TestCase):
|
||||
_msg(" file={}".format(out_file))
|
||||
_msg(" exists={}".format(os.path.exists(out_file)))
|
||||
|
||||
Draft.export_OCA = aux._fake_function
|
||||
obj = Draft.export_OCA(out_file)
|
||||
Draft.export_oca = aux.fake_function
|
||||
obj = Draft.export_oca(out_file)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def tearDown(self):
|
||||
|
||||
@@ -39,7 +39,7 @@ class DraftPivy(unittest.TestCase):
|
||||
This is executed before every test, so we create a document
|
||||
to hold the objects.
|
||||
"""
|
||||
aux._draw_header()
|
||||
aux.draw_header()
|
||||
self.doc_name = self.__class__.__name__
|
||||
if App.ActiveDocument:
|
||||
if App.ActiveDocument.Name != self.doc_name:
|
||||
@@ -53,7 +53,7 @@ class DraftPivy(unittest.TestCase):
|
||||
def test_pivy_import(self):
|
||||
"""Import Coin (Pivy)."""
|
||||
module = "pivy.coin"
|
||||
imported = aux._import_test(module)
|
||||
imported = aux.import_test(module)
|
||||
self.assertTrue(imported, "Problem importing '{}'".format(module))
|
||||
|
||||
def test_pivy_draw(self):
|
||||
|
||||
@@ -40,7 +40,7 @@ class DraftSVG(unittest.TestCase):
|
||||
This is executed before every test, so we create a document
|
||||
to hold the objects.
|
||||
"""
|
||||
aux._draw_header()
|
||||
aux.draw_header()
|
||||
self.doc_name = self.__class__.__name__
|
||||
if App.ActiveDocument:
|
||||
if App.ActiveDocument.Name != self.doc_name:
|
||||
@@ -62,8 +62,8 @@ class DraftSVG(unittest.TestCase):
|
||||
_msg(" file={}".format(in_file))
|
||||
_msg(" exists={}".format(os.path.exists(in_file)))
|
||||
|
||||
Draft.import_SVG = aux._fake_function
|
||||
obj = Draft.import_SVG(in_file)
|
||||
Draft.import_svg = aux.fake_function
|
||||
obj = Draft.import_svg(in_file)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def test_export_svg(self):
|
||||
@@ -76,8 +76,8 @@ class DraftSVG(unittest.TestCase):
|
||||
_msg(" file={}".format(out_file))
|
||||
_msg(" exists={}".format(os.path.exists(out_file)))
|
||||
|
||||
Draft.export_SVG = aux._fake_function
|
||||
obj = Draft.export_SVG(out_file)
|
||||
Draft.export_svg = aux.fake_function
|
||||
obj = Draft.export_svg(out_file)
|
||||
self.assertTrue(obj, "'{}' failed".format(operation))
|
||||
|
||||
def tearDown(self):
|
||||
|
||||
Reference in New Issue
Block a user