Skip to content

Commit

Permalink
Merge pull request FreeCAD#18857 from Roy-043/Draft-Minor-cosmetic-ch…
Browse files Browse the repository at this point in the history
…anges-to-test-files

Draft: Minor cosmetic changes to test files
  • Loading branch information
Roy-043 authored Jan 4, 2025
2 parents b639b20 + 2b35ad2 commit a974e41
Show file tree
Hide file tree
Showing 16 changed files with 124 additions and 96 deletions.
3 changes: 3 additions & 0 deletions src/Mod/Draft/drafttests/auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions src/Mod/Draft/drafttests/draft_test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
::
Expand All @@ -34,20 +35,22 @@
>>> 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
Expand Down
12 changes: 7 additions & 5 deletions src/Mod/Draft/drafttests/test_airfoildat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -48,7 +50,7 @@ def test_read_airfoildat(self):
_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)))
Expand All @@ -62,7 +64,7 @@ def test_export_airfoildat(self):
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)))
Expand Down
22 changes: 10 additions & 12 deletions src/Mod/Draft/drafttests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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)

## @}
2 changes: 2 additions & 0 deletions src/Mod/Draft/drafttests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
# * *
# ***************************************************************************

"""Unit tests for the Draft Workbench, base classes."""

import unittest

import FreeCAD as App
Expand Down
7 changes: 4 additions & 3 deletions src/Mod/Draft/drafttests/test_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
81 changes: 41 additions & 40 deletions src/Mod/Draft/drafttests/test_draftgeomutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -62,10 +63,10 @@ def test_get_extended_wire1(self):
_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:]):
Expand All @@ -80,10 +81,10 @@ def test_get_extended_wire2(self):
_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:]):
Expand All @@ -99,10 +100,10 @@ def test_get_extended_wire3(self):
_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:]):
Expand All @@ -119,10 +120,10 @@ def test_get_extended_wire4(self):
_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:]):
Expand All @@ -138,11 +139,11 @@ def test_get_extended_wire5(self):
_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:]):
Expand All @@ -157,11 +158,11 @@ def test_get_extended_wire6(self):
_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:]):
Expand All @@ -177,11 +178,11 @@ def test_get_extended_wire7(self):
_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:]):
Expand All @@ -198,11 +199,11 @@ def test_get_extended_wire8(self):
_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:]):
Expand Down
11 changes: 6 additions & 5 deletions src/Mod/Draft/drafttests/test_dwg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -48,7 +49,7 @@ def test_read_dwg(self):
_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)))
Expand All @@ -62,7 +63,7 @@ def test_export_dwg(self):
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)))
Expand Down
Loading

0 comments on commit a974e41

Please sign in to comment.