Merge pull request #18857 from Roy-043/Draft-Minor-cosmetic-changes-to-test-files

Draft: Minor cosmetic changes to test files
This commit is contained in:
Roy-043
2025-01-04 01:16:48 +01:00
committed by GitHub
16 changed files with 125 additions and 97 deletions

View File

@@ -21,13 +21,16 @@
# * USA *
# * *
# ***************************************************************************
"""Auxiliary functions for the unit tests of the Draft Workbench."""
## @package auxiliary
# \ingroup drafttests
# \brief Auxiliary functions for the unit tests of the Draft Workbench.
## \addtogroup drafttests
# @{
import traceback
from draftutils.messages import _msg

View File

@@ -21,9 +21,10 @@
# * USA *
# * *
# ***************************************************************************
"""Run this file to create a standard test document for Draft objects.
Use it as input to the program executable.
Use it as input for the program executable.
::
@@ -34,20 +35,22 @@ Or load it as a module and use the defined function.
>>> import drafttests.draft_test_objects as dt
>>> dt.create_test_file()
"""
## @package draft_test_objects
# \ingroup drafttests
# \brief Run this file to create a standard test document for Draft objects.
## \addtogroup drafttests
# @{
import datetime
import FreeCAD as App
import Part
import Draft
from draftutils.messages import _msg, _wrn
from FreeCAD import Vector
from draftutils.messages import _msg, _wrn
if App.GuiUp:
import FreeCADGui as Gui

View File

@@ -22,21 +22,23 @@
# * USA *
# * *
# ***************************************************************************
"""Unit tests for the Draft Workbench, Airfoil DAT import and export tests."""
## @package test_airfoildat
# \ingroup drafttests
# \brief Unit tests for the Draft Workbench, Airfoil DAT tests.
## \addtogroup drafttests
# @{
import os
import FreeCAD as App
import Draft
import drafttests.auxiliary as aux
from draftutils.messages import _msg
from drafttests import auxiliary as aux
from drafttests import test_base
from draftutils.messages import _msg
class DraftAirfoilDAT(test_base.DraftTestCaseDoc):
@@ -48,7 +50,7 @@ class DraftAirfoilDAT(test_base.DraftTestCaseDoc):
_msg(" Test '{}'".format(operation))
_msg(" This test requires a DAT file with airfoil data to read.")
file = 'Mod/Draft/drafttest/test.dat'
file = "Mod/Draft/drafttest/test.dat"
in_file = os.path.join(App.getResourceDir(), file)
_msg(" file={}".format(in_file))
_msg(" exists={}".format(os.path.exists(in_file)))
@@ -62,7 +64,7 @@ class DraftAirfoilDAT(test_base.DraftTestCaseDoc):
operation = "importAirfoilDAT.export"
_msg(" Test '{}'".format(operation))
file = 'Mod/Draft/drafttest/out_test.dat'
file = "Mod/Draft/drafttest/out_test.dat"
out_file = os.path.join(App.getResourceDir(), file)
_msg(" file={}".format(out_file))
_msg(" exists={}".format(os.path.exists(out_file)))

View File

@@ -19,20 +19,18 @@
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
"""Unit tests for the Draft Workbench, array tests."""
## @package test_array
# \ingroup drafttests
# \brief Unit tests for the Draft Workbench, array tests.
## \addtogroup drafttests
# @{
import math
import FreeCAD as App
import Draft
from FreeCAD import Vector
from draftutils.messages import _msg
from drafttests import test_base
@@ -41,29 +39,29 @@ class DraftArray(test_base.DraftTestCaseDoc):
def test_link_array(self):
"""Create a link array."""
box = self.doc.addObject("Part::Box","Box")
box = self.doc.addObject("Part::Box", "Box")
box.Label = "Box"
self.doc.recompute()
array = Draft.make_ortho_array(box, v_x=App.Vector(100.0, 0.0, 0.0),
v_y=App.Vector(0.0, 100.0, 0.0),
v_z=App.Vector(0.0, 0.0, 100.0),
array = Draft.make_ortho_array(box, v_x=Vector(100.0, 0.0, 0.0),
v_y=Vector(0.0, 100.0, 0.0),
v_z=Vector(0.0, 0.0, 100.0),
n_x=12, n_y=1, n_z=1, use_link=True)
Draft.autogroup(array)
array.ExpandArray = True
array.Fuse = False
self.doc.recompute(None,True,True)
self.doc.recompute(None, True, True)
array.NumberX = 6
self.doc.recompute(None,True,True)
self.doc.recompute(None, True, True)
self.assertEqual(array.Count, array.NumberX)
array.NumberX = 24
self.doc.recompute(None,True,True)
self.doc.recompute(None, True, True)
self.assertEqual(array.Count, array.NumberX)
self.doc.recompute(None,True,True)
self.doc.recompute(None, True, True)
self.assertEqual(array.Count, array.NumberX)
## @}

View File

@@ -21,6 +21,8 @@
# * *
# ***************************************************************************
"""Unit tests for the Draft Workbench, base classes."""
import unittest
import FreeCAD as App

View File

@@ -22,22 +22,23 @@
# * USA *
# * *
# ***************************************************************************
"""Unit tests for the Draft Workbench, object creation tests."""
## @package test_creation
# \ingroup drafttests
# \brief Unit tests for the Draft Workbench, object creation tests.
## \addtogroup drafttests
# @{
import math
import FreeCAD as App
import Draft
import drafttests.auxiliary as aux
from FreeCAD import Vector
from draftutils.messages import _msg
from drafttests import test_base
from draftutils.messages import _msg
class DraftCreation(test_base.DraftTestCaseDoc):

View File

@@ -21,14 +21,15 @@
# * USA *
# * *
# ***************************************************************************
"""Unit test for the DraftGeomUtils module."""
import FreeCAD
"""Unit tests for the Draft Workbench, DraftGeomUtils module tests."""
import Part
import DraftGeomUtils
import drafttests.auxiliary as aux
from draftutils.messages import _msg
from FreeCAD import Vector
from drafttests import test_base
from draftutils.messages import _msg
class TestDraftGeomUtils(test_base.DraftTestCaseNoDoc):
"""Testing the functions in the file DraftGeomUtils.py"""
@@ -62,10 +63,10 @@ class TestDraftGeomUtils(test_base.DraftTestCaseNoDoc):
_msg(" Test '{}'".format(operation))
# Build wires made with straight edges and various combination of Orientation: the wires 1-4 are all equivalent
points = [FreeCAD.Vector(0.0, 0.0, 0.0),
FreeCAD.Vector(1500.0, 2000.0, 0.0),
FreeCAD.Vector(4500.0, 2000.0, 0.0),
FreeCAD.Vector(4500.0, 2000.0, 2500.0)]
points = [Vector(0.0, 0.0, 0.0),
Vector(1500.0, 2000.0, 0.0),
Vector(4500.0, 2000.0, 0.0),
Vector(4500.0, 2000.0, 2500.0)]
edges = []
for start, end in zip(points[:-1], points[1:]):
@@ -80,10 +81,10 @@ class TestDraftGeomUtils(test_base.DraftTestCaseNoDoc):
_msg(" Test '{}'".format(operation))
# Build wires made with straight edges and various combination of Orientation: the wires 1-4 are all equivalent
points = [FreeCAD.Vector(0.0, 0.0, 0.0),
FreeCAD.Vector(1500.0, 2000.0, 0.0),
FreeCAD.Vector(4500.0, 2000.0, 0.0),
FreeCAD.Vector(4500.0, 2000.0, 2500.0)]
points = [Vector(0.0, 0.0, 0.0),
Vector(1500.0, 2000.0, 0.0),
Vector(4500.0, 2000.0, 0.0),
Vector(4500.0, 2000.0, 2500.0)]
edges = []
for start, end in zip(points[:-1], points[1:]):
@@ -99,10 +100,10 @@ class TestDraftGeomUtils(test_base.DraftTestCaseNoDoc):
_msg(" Test '{}'".format(operation))
# Build wires made with straight edges and various combination of Orientation: the wires 1-4 are all equivalent
points = [FreeCAD.Vector(0.0, 0.0, 0.0),
FreeCAD.Vector(1500.0, 2000.0, 0.0),
FreeCAD.Vector(4500.0, 2000.0, 0.0),
FreeCAD.Vector(4500.0, 2000.0, 2500.0)]
points = [Vector(0.0, 0.0, 0.0),
Vector(1500.0, 2000.0, 0.0),
Vector(4500.0, 2000.0, 0.0),
Vector(4500.0, 2000.0, 2500.0)]
edges = []
for start, end in zip(points[:-1], points[1:]):
@@ -119,10 +120,10 @@ class TestDraftGeomUtils(test_base.DraftTestCaseNoDoc):
_msg(" Test '{}'".format(operation))
# Build wires made with straight edges and various combination of Orientation: the wires 1-4 are all equivalent
points = [FreeCAD.Vector(0.0, 0.0, 0.0),
FreeCAD.Vector(1500.0, 2000.0, 0.0),
FreeCAD.Vector(4500.0, 2000.0, 0.0),
FreeCAD.Vector(4500.0, 2000.0, 2500.0)]
points = [Vector(0.0, 0.0, 0.0),
Vector(1500.0, 2000.0, 0.0),
Vector(4500.0, 2000.0, 0.0),
Vector(4500.0, 2000.0, 2500.0)]
edges = []
for start, end in zip(points[:-1], points[1:]):
@@ -138,11 +139,11 @@ class TestDraftGeomUtils(test_base.DraftTestCaseNoDoc):
_msg(" Test '{}'".format(operation))
# Build wires made with arcs and various combination of Orientation: the wires 5-8 are all equivalent
points = [FreeCAD.Vector(0.0, 0.0, 0.0),
FreeCAD.Vector(1000.0, 1000.0, 0.0),
FreeCAD.Vector(2000.0, 0.0, 0.0),
FreeCAD.Vector(3000.0, 0.0, 1000.0),
FreeCAD.Vector(4000.0, 0.0, 0.0)]
points = [Vector(0.0, 0.0, 0.0),
Vector(1000.0, 1000.0, 0.0),
Vector(2000.0, 0.0, 0.0),
Vector(3000.0, 0.0, 1000.0),
Vector(4000.0, 0.0, 0.0)]
edges = []
for start, mid, end in zip(points[:-2], points[1:-1], points[2:]):
@@ -157,11 +158,11 @@ class TestDraftGeomUtils(test_base.DraftTestCaseNoDoc):
_msg(" Test '{}'".format(operation))
# Build wires made with arcs and various combination of Orientation: the wires 5-8 are all equivalent
points = [FreeCAD.Vector(0.0, 0.0, 0.0),
FreeCAD.Vector(1000.0, 1000.0, 0.0),
FreeCAD.Vector(2000.0, 0.0, 0.0),
FreeCAD.Vector(3000.0, 0.0, 1000.0),
FreeCAD.Vector(4000.0, 0.0, 0.0)]
points = [Vector(0.0, 0.0, 0.0),
Vector(1000.0, 1000.0, 0.0),
Vector(2000.0, 0.0, 0.0),
Vector(3000.0, 0.0, 1000.0),
Vector(4000.0, 0.0, 0.0)]
edges = []
for start, mid, end in zip(points[:-2], points[1:-1], points[2:]):
@@ -177,11 +178,11 @@ class TestDraftGeomUtils(test_base.DraftTestCaseNoDoc):
_msg(" Test '{}'".format(operation))
# Build wires made with arcs and various combination of Orientation: the wires 5-8 are all equivalent
points = [FreeCAD.Vector(0.0, 0.0, 0.0),
FreeCAD.Vector(1000.0, 1000.0, 0.0),
FreeCAD.Vector(2000.0, 0.0, 0.0),
FreeCAD.Vector(3000.0, 0.0, 1000.0),
FreeCAD.Vector(4000.0, 0.0, 0.0)]
points = [Vector(0.0, 0.0, 0.0),
Vector(1000.0, 1000.0, 0.0),
Vector(2000.0, 0.0, 0.0),
Vector(3000.0, 0.0, 1000.0),
Vector(4000.0, 0.0, 0.0)]
edges = []
for start, mid, end in zip(points[:-2], points[1:-1], points[2:]):
@@ -198,11 +199,11 @@ class TestDraftGeomUtils(test_base.DraftTestCaseNoDoc):
_msg(" Test '{}'".format(operation))
# Build wires made with arcs and various combination of Orientation: the wires 5-8 are all equivalent
points = [FreeCAD.Vector(0.0, 0.0, 0.0),
FreeCAD.Vector(1000.0, 1000.0, 0.0),
FreeCAD.Vector(2000.0, 0.0, 0.0),
FreeCAD.Vector(3000.0, 0.0, 1000.0),
FreeCAD.Vector(4000.0, 0.0, 0.0)]
points = [Vector(0.0, 0.0, 0.0),
Vector(1000.0, 1000.0, 0.0),
Vector(2000.0, 0.0, 0.0),
Vector(3000.0, 0.0, 1000.0),
Vector(4000.0, 0.0, 0.0)]
edges = []
for start, mid, end in zip(points[:-2], points[1:-1], points[2:]):

View File

@@ -23,20 +23,21 @@
# * *
# ***************************************************************************
"""Unit tests for the Draft Workbench, DWG import and export tests."""
## @package test_dwg
# \ingroup drafttests
# \brief Unit tests for the Draft Workbench, DWG import and export tests.
## \addtogroup drafttests
# @{
import os
import FreeCAD as App
import Draft
import drafttests.auxiliary as aux
from draftutils.messages import _msg
from drafttests import auxiliary as aux
from drafttests import test_base
from draftutils.messages import _msg
class DraftDWG(test_base.DraftTestCaseDoc):
@@ -48,7 +49,7 @@ class DraftDWG(test_base.DraftTestCaseDoc):
_msg(" Test '{}'".format(operation))
_msg(" This test requires a DWG file to read.")
file = 'Mod/Draft/drafttest/test.dwg'
file = "Mod/Draft/drafttest/test.dwg"
in_file = os.path.join(App.getResourceDir(), file)
_msg(" file={}".format(in_file))
_msg(" exists={}".format(os.path.exists(in_file)))
@@ -62,7 +63,7 @@ class DraftDWG(test_base.DraftTestCaseDoc):
operation = "importDWG.export"
_msg(" Test '{}'".format(operation))
file = 'Mod/Draft/drafttest/out_test.dwg'
file = "Mod/Draft/drafttest/out_test.dwg"
out_file = os.path.join(App.getResourceDir(), file)
_msg(" file={}".format(out_file))
_msg(" exists={}".format(os.path.exists(out_file)))

View File

@@ -22,21 +22,23 @@
# * USA *
# * *
# ***************************************************************************
"""Unit tests for the Draft Workbench, DXF import and export tests."""
## @package test_dxf
# \ingroup drafttests
# \brief Unit tests for the Draft Workbench, DXF import and export tests.
## \addtogroup drafttests
# @{
import os
import FreeCAD as App
import Draft
import drafttests.auxiliary as aux
from draftutils.messages import _msg
from drafttests import auxiliary as aux
from drafttests import test_base
from draftutils.messages import _msg
class DraftDXF(test_base.DraftTestCaseDoc):
@@ -48,7 +50,7 @@ class DraftDXF(test_base.DraftTestCaseDoc):
_msg(" Test '{}'".format(operation))
_msg(" This test requires a DXF file to read.")
file = 'Mod/Draft/drafttest/test.dxf'
file = "Mod/Draft/drafttest/test.dxf"
in_file = os.path.join(App.getResourceDir(), file)
_msg(" file={}".format(in_file))
_msg(" exists={}".format(os.path.exists(in_file)))
@@ -62,7 +64,7 @@ class DraftDXF(test_base.DraftTestCaseDoc):
operation = "importDXF.export"
_msg(" Test '{}'".format(operation))
file = 'Mod/Draft/drafttest/out_test.dxf'
file = "Mod/Draft/drafttest/out_test.dxf"
out_file = os.path.join(App.getResourceDir(), file)
_msg(" file={}".format(out_file))
_msg(" exists={}".format(os.path.exists(out_file)))

View File

@@ -22,14 +22,17 @@
# * USA *
# * *
# ***************************************************************************
"""Unit tests for the Draft Workbench, import tests."""
## @package test_import
# \ingroup drafttests
# \brief Unit tests for the Draft Workbench, import tests.
## \addtogroup drafttests
# @{
import drafttests.auxiliary as aux
from drafttests import auxiliary as aux
from drafttests import test_base

View File

@@ -22,14 +22,17 @@
# * USA *
# * *
# ***************************************************************************
"""Unit tests for the Draft Workbench, GUI import tests."""
## @package test_import_gui
# \ingroup drafttests
# \brief Unit tests for the Draft Workbench, GUI import tests.
## \addtogroup drafttests
# @{
import drafttests.auxiliary as aux
from drafttests import auxiliary as aux
from drafttests import test_base

View File

@@ -23,13 +23,15 @@
# * *
# ***************************************************************************
"""Unit tests for the Draft Workbench, tools import tests."""
## @package test_import_tools
# \ingroup drafttests
# \brief Unit tests for the Draft Workbench, tools import tests.
## \addtogroup drafttests
# @{
import drafttests.auxiliary as aux
from drafttests import auxiliary as aux
from drafttests import test_base

View File

@@ -22,21 +22,23 @@
# * USA *
# * *
# ***************************************************************************
"""Unit tests for the Draft Workbench, object modification tests."""
## @package test_modification
# \ingroup drafttests
# \brief Unit tests for the Draft Workbench, object modification tests.
## \addtogroup drafttests
# @{
import FreeCAD as App
import Draft
import drafttests.auxiliary as aux
import Part
import FreeCAD as App
import Part
import Draft
from FreeCAD import Vector
from draftutils.messages import _msg, _wrn
from drafttests import auxiliary as aux
from drafttests import test_base
from draftutils.messages import _msg
class DraftModification(test_base.DraftTestCaseDoc):

View File

@@ -22,21 +22,23 @@
# * USA *
# * *
# ***************************************************************************
"""Unit tests for the Draft Workbench, OCA import and export tests."""
## @package test_oca
# \ingroup drafttests
# \brief Unit tests for the Draft Workbench, OCA import and export tests.
## \addtogroup drafttests
# @{
import os
import FreeCAD as App
import Draft
import drafttests.auxiliary as aux
from draftutils.messages import _msg
from drafttests import auxiliary as aux
from drafttests import test_base
from draftutils.messages import _msg
class DraftOCA(test_base.DraftTestCaseDoc):
@@ -48,7 +50,7 @@ class DraftOCA(test_base.DraftTestCaseDoc):
_msg(" Test '{}'".format(operation))
_msg(" This test requires an OCA file to read.")
file = 'Mod/Draft/drafttest/test.oca'
file = "Mod/Draft/drafttest/test.oca"
in_file = os.path.join(App.getResourceDir(), file)
_msg(" file={}".format(in_file))
_msg(" exists={}".format(os.path.exists(in_file)))
@@ -62,7 +64,7 @@ class DraftOCA(test_base.DraftTestCaseDoc):
operation = "importOCA.export"
_msg(" Test '{}'".format(operation))
file = 'Mod/Draft/drafttest/out_test.oca'
file = "Mod/Draft/drafttest/out_test.oca"
out_file = os.path.join(App.getResourceDir(), file)
_msg(" file={}".format(out_file))
_msg(" exists={}".format(os.path.exists(out_file)))

View File

@@ -22,18 +22,20 @@
# * USA *
# * *
# ***************************************************************************
"""Unit tests for the Draft Workbench, Coin (Pivy) tests."""
## @package test_pivy
# \ingroup drafttests
# \brief Unit tests for the Draft Workbench, Coin (Pivy) tests.
## \addtogroup drafttests
# @{
import FreeCADGui as Gui
import drafttests.auxiliary as aux
from draftutils.messages import _msg
import FreeCADGui as Gui
from drafttests import auxiliary as aux
from drafttests import test_base
from draftutils.messages import _msg
class DraftPivy(test_base.DraftTestCaseDoc):

View File

@@ -23,21 +23,22 @@
# * *
# ***************************************************************************
"""Unit tests for the Draft Workbench, SVG import and export tests."""
## @package test_svg
# \ingroup drafttests
# \brief Unit tests for the Draft Workbench, SVG import and export tests.
## \addtogroup drafttests
# @{
import os
import unittest
import FreeCAD as App
import Draft
import drafttests.auxiliary as aux
from draftutils.messages import _msg
from drafttests import auxiliary as aux
from drafttests import test_base
from draftutils.messages import _msg
try:
import Arch
@@ -56,7 +57,7 @@ class DraftSVG(test_base.DraftTestCaseDoc):
_msg(" Test '{}'".format(operation))
_msg(" This test requires an SVG file to read.")
file = 'Mod/Draft/drafttest/test.svg'
file = "Mod/Draft/drafttest/test.svg"
in_file = os.path.join(App.getResourceDir(), file)
_msg(" file={}".format(in_file))
_msg(" exists={}".format(os.path.exists(in_file)))
@@ -70,7 +71,7 @@ class DraftSVG(test_base.DraftTestCaseDoc):
operation = "importSVG.export"
_msg(" Test '{}'".format(operation))
file = 'Mod/Draft/drafttest/out_test.svg'
file = "Mod/Draft/drafttest/out_test.svg"
out_file = os.path.join(App.getResourceDir(), file)
_msg(" file={}".format(out_file))
_msg(" exists={}".format(os.path.exists(out_file)))
@@ -85,15 +86,15 @@ class DraftSVG(test_base.DraftTestCaseDoc):
import Part
import Draft
sb = Part.makeBox(1,1,1)
b = self.doc.addObject('Part::Feature','Box')
sb = Part.makeBox(1, 1, 1)
b = self.doc.addObject("Part::Feature", "Box")
b.Shape = sb
s = Arch.makeSpace(b)
self.doc.recompute()
try:
Draft.get_svg(s, direction=App.Vector(0,0,0))
Draft.get_svg(s, direction=App.Vector(0, 0, 0))
except AttributeError as err:
self.fail("Cryptic exception thrown: {}".format(err))
except ValueError as err: