- I've finally run the tests with OK result (56 tests in 102.937 sec)

- I had to play with module imports as they created a lot of error in
the tests although in reality the program worked OK.
- I've fixed some mistakes in TcL commands (they were testing isinstance
against the like of Geometry instead of FlatCAMGeometry)
- I've had to add some fixes in ObjectCollections.py (error on
create_index() method but Marco already fixed this in the checkbox
in project tab pull request and knew about this.
- Although at some point the tests run fine, I've made some checkings
on my own over the Tcl commands and discovered errors which I fixed as
mentioned above.
- conclusion is that tests are just a must and do not cover everything
(like saving projects which at some point by juggling with imports I
braked and tests were 100% OK)
This commit is contained in:
Marius Stanciu
2018-05-30 02:17:34 +03:00
parent da9f890c39
commit 3b9767cc6f
47 changed files with 63 additions and 105 deletions

View File

@@ -17,7 +17,7 @@ import re
import webbrowser
import os
import tkinter
from PyQt4 import QtCore
from PyQt4 import Qt, QtCore, QtGui
import time # Just used for debugging. Double check before removing.
from xml.dom.minidom import parseString as parse_xml_string
from contextlib import contextmanager
@@ -27,10 +27,10 @@ from contextlib import contextmanager
########################################
import FlatCAMVersion
from FlatCAMWorker import Worker
from ObjectCollection import *
from FlatCAMObj import *
from PlotCanvas import *
from FlatCAMGUI import *
import ObjectCollection
from FlatCAMObj import FlatCAMCNCjob, FlatCAMExcellon, FlatCAMGerber, FlatCAMGeometry, FlatCAMObj
from PlotCanvas import PlotCanvas
from FlatCAMGUI import FlatCAMGUI, GlobalOptionsUI, FlatCAMActivityView, FlatCAMInfoBar
from FlatCAMCommon import LoudDict
from FlatCAMShell import FCShell
from FlatCAMDraw import FlatCAMDraw
@@ -39,6 +39,8 @@ from MeasurementTool import Measurement
from DblSidedTool import DblSidedTool
import tclCommands
from camlib import *
########################################
## App ##
@@ -471,7 +473,7 @@ class App(QtCore.QObject):
#self.options_write_form()
self.on_options_combo_change(0) # Will show the initial form
self.collection = ObjectCollection()
self.collection = ObjectCollection.ObjectCollection()
self.ui.project_tab_layout.addWidget(self.collection.view)
#### End of Data ####
@@ -1065,7 +1067,7 @@ class App(QtCore.QObject):
t3 = time.time()
self.log.debug("%f seconds converting units." % (t3 - t2))
FlatCAMApp.App.log.debug("Moving new object back to main thread.")
self.log.debug("Moving new object back to main thread.")
# Move the object to the main thread and let the app know that it is available.
obj.moveToThread(QtGui.QApplication.instance().thread())

View File

@@ -221,7 +221,7 @@ class FlatCAMObj(QtCore.QObject):
try:
self.form_fields[option].set_value(self.options[option])
except KeyError:
self.app.log.warn("Tried to set an option or field that does not exist: %s" % option)
self.app.log.warning("Tried to set an option or field that does not exist: %s" % option)
def read_form_item(self, option):
"""

View File

@@ -6,7 +6,6 @@
# MIT Licence #
############################################################
#from PyQt4.QtCore import QModelIndex
from FlatCAMObj import *
import inspect # TODO: Remove
import FlatCAMApp
@@ -162,13 +161,13 @@ class ObjectCollection():
self.object_list.append(obj)
# Create the model item to insert into the QListView
icon = QtGui.QIcon(self.icons[obj.kind])#self.icons["gerber"])
item = QtGui.QStandardItem(icon, name)
icon = QtGui.QIcon(self.icons[obj.kind]) #self.icons["gerber"])
item = QtGui.QStandardItem(icon, str(name))
item.setCheckable(True)
if obj.options["plot"] == True:
item.setCheckState(2)#Qt.Checked)
if obj.options["plot"] is True:
item.setCheckState(2) #Qt.Checked)
else:
item.setCheckState(0) #Qt.Unchecked)
item.setCheckState(0) #Qt.Unchecked)
self.model.appendRow(item)
@@ -289,7 +288,7 @@ class ObjectCollection():
:param name: Name of the FlatCAM Object
:return: None
"""
iobj = self.createIndex(self.get_names().index(name), 0) # Column 0
iobj = self.model.createIndex(self.get_names().index(name), 0) # Column 0
self.view.selectionModel().select(iobj, QtGui.QItemSelectionModel.Select)
def set_inactive(self, name):
@@ -300,7 +299,7 @@ class ObjectCollection():
:param name: Name of the FlatCAM Object
:return: None
"""
iobj = self.createIndex(self.get_names().index(name), 0) # Column 0
iobj = self.model.createIndex(self.get_names().index(name), 0) # Column 0
self.view.selectionModel().select(iobj, QtGui.QItemSelectionModel.Deselect)
def set_all_inactive(self):

View File

@@ -5,6 +5,7 @@ import abc
import collections
from PyQt4 import QtCore
from contextlib import contextmanager
from FlatCAMObj import FlatCAMGerber, FlatCAMExcellon, FlatCAMGeometry, FlatCAMCNCjob, FlatCAMObj
class TclCommand(object):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommand
from tclCommands.TclCommand import *
class TclCommandAddCircle(TclCommand):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandAddPolygon(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandAddPolyline(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandAddRectangle(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandAlignDrill(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandAlignDrillGrid(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandCncjob(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommand
from tclCommands.TclCommand import *
class TclCommandCutout(TclCommand):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommand
from tclCommands.TclCommand import *
class TclCommandDelete(TclCommand):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandDrillcncjob(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandExportGcode(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommand
from tclCommands.TclCommand import *
class TclCommandExportSVG(TclCommand):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandExteriors(TclCommandSignaled):
@@ -54,7 +53,7 @@ class TclCommandExteriors(TclCommandSignaled):
if obj is None:
self.raise_tcl_error("Object not found: %s" % name)
if not isinstance(obj, Geometry):
if not isinstance(obj, FlatCAMGeometry):
self.raise_tcl_error('Expected Geometry, got %s %s.' % (name, type(obj)))
def geo_init(geo_obj, app_obj):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandGeoCutout(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommand
from tclCommands.TclCommand import *
class TclCommandGeoUnion(TclCommand):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommand
from tclCommands.TclCommand import *
class TclCommandGetNames(TclCommand):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommand
from tclCommands.TclCommand import *
class TclCommandGetSys(TclCommand):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandImportSvg(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandInteriors(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandIsolate(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommand
from tclCommands.TclCommand import *
class TclCommandJoinExcellon(TclCommand):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommand
from tclCommands.TclCommand import *
class TclCommandJoinGeometry(TclCommand):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandMillHoles(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandMirror(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommand
from tclCommands.TclCommand import *
class TclCommandNew(TclCommand):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandNewGeometry(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommand
from tclCommands.TclCommand import *
class TclCommandOffset(TclCommand):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandOpenExcellon(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandOpenGCode(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandOpenGerber(TclCommandSignaled):
@@ -48,7 +47,7 @@ class TclCommandOpenGerber(TclCommandSignaled):
# How the object should be initialized
def obj_init(gerber_obj, app_obj):
if not isinstance(gerber_obj, Geometry):
if not isinstance(gerber_obj, FlatCAMGerber):
self.raise_tcl_error('Expected FlatCAMGerber, got %s %s.' % (outname, type(gerber_obj)))
# Opening the file happens here

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandOpenProject(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandOptions(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandPaint(TclCommandSignaled):

View File

@@ -1,7 +1,5 @@
from ObjectCollection import *
from copy import copy,deepcopy
from tclCommands.TclCommand import TclCommand
from tclCommands.TclCommand import *
class TclCommandPanelize(TclCommand):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommand
from tclCommands.TclCommand import *
class TclCommandPlot(TclCommand):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandSaveProject(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommand
from tclCommands.TclCommand import *
class TclCommandScale(TclCommand):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommand
from tclCommands.TclCommand import *
class TclCommandSetActive(TclCommand):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommand
from tclCommands.TclCommand import *
class TclCommandSetSys(TclCommand):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandSubtractPoly(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandSubtractRectangle(TclCommandSignaled):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommand
from tclCommands.TclCommand import *
class TclCommandVersion(TclCommand):

View File

@@ -1,5 +1,4 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from tclCommands.TclCommand import *
class TclCommandWriteGCode(TclCommandSignaled):