Skip to content

Commit

Permalink
Draft: unit tests registered in Init.py
Browse files Browse the repository at this point in the history
This means that now the unit tests will run from
the console mode when using
```
FreeCADCmd -t 0
FreeCAD --console -t 0
```

This will allow us to catch errors more easily,
as we separate better the behavior of non-GUI
and GUI-required modules.

Also small spacing fixes and position of the license.
  • Loading branch information
vocx-fc authored and yorikvanhavre committed Apr 8, 2020
1 parent 7d8ab17 commit c55a5a9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 40 deletions.
63 changes: 34 additions & 29 deletions src/Mod/Draft/Init.py
@@ -1,31 +1,36 @@
#***************************************************************************
#* Copyright (c) 2009 Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
# ***************************************************************************
# * Copyright (c) 2009 Yorik van Havre <yorik@uncreated.net> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
"""Initialization file of the workbench, non-GUI."""

import FreeCAD as App

# add Import/Export types
App.addImportType("Autodesk DXF 2D (*.dxf)","importDXF")
App.addImportType("SVG as geometry (*.svg)","importSVG")
App.addImportType("Open CAD Format (*.oca *.gcad)","importOCA")
App.addImportType("Common airfoil data (*.dat)","importAirfoilDAT")
App.addExportType("Autodesk DXF 2D (*.dxf)","importDXF")
App.addExportType("Flattened SVG (*.svg)","importSVG")
App.addExportType("Open CAD Format (*.oca)","importOCA")
App.addImportType("Autodesk DWG 2D (*.dwg)","importDWG")
App.addExportType("Autodesk DWG 2D (*.dwg)","importDWG")
App.addImportType("Autodesk DXF 2D (*.dxf)", "importDXF")
App.addImportType("SVG as geometry (*.svg)", "importSVG")
App.addImportType("Open CAD Format (*.oca *.gcad)", "importOCA")
App.addImportType("Common airfoil data (*.dat)", "importAirfoilDAT")
App.addExportType("Autodesk DXF 2D (*.dxf)", "importDXF")
App.addExportType("Flattened SVG (*.svg)", "importSVG")
App.addExportType("Open CAD Format (*.oca)", "importOCA")
App.addImportType("Autodesk DWG 2D (*.dwg)", "importDWG")
App.addExportType("Autodesk DWG 2D (*.dwg)", "importDWG")

App.__unit_test__ += ["TestDraft"]
2 changes: 0 additions & 2 deletions src/Mod/Draft/InitGui.py
Expand Up @@ -174,5 +174,3 @@ def GetClassName(self):
FreeCADGui.addPreferencePage(":/ui/preferences-dwg.ui", QT_TRANSLATE_NOOP("Draft", "Import-Export"))
FreeCADGui.addPreferencePage(":/ui/preferences-svg.ui", QT_TRANSLATE_NOOP("Draft", "Import-Export"))
FreeCADGui.addPreferencePage(":/ui/preferences-oca.ui", QT_TRANSLATE_NOOP("Draft", "Import-Export"))

FreeCAD.__unit_test__ += ["TestDraft"]
18 changes: 9 additions & 9 deletions src/Mod/Draft/TestDraft.py
@@ -1,12 +1,3 @@
"""Unit tests for the Draft workbench.
From the terminal, run the following:
FreeCAD -t TestDraft
From within FreeCAD, run the following:
import Test, TestDraft
Test.runTestsFromModule(TestDraft)
"""
# ***************************************************************************
# * Copyright (c) 2013 Yorik van Havre <yorik@uncreated.net> *
# * Copyright (c) 2019 Eliud Cabrera Castillo <e.cabrera-castillo@tum.de> *
Expand All @@ -30,6 +21,15 @@
# * USA *
# * *
# ***************************************************************************
"""Unit tests for the Draft workbench.
From the terminal, run the following:
FreeCAD -t TestDraft
From within FreeCAD, run the following:
import Test, TestDraft
Test.runTestsFromModule(TestDraft)
"""

# ===========================================================================
# The unit tests can be run from the operating system terminal, or from
Expand Down

0 comments on commit c55a5a9

Please sign in to comment.