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

View File

@@ -221,7 +221,7 @@ class FlatCAMObj(QtCore.QObject):
try: try:
self.form_fields[option].set_value(self.options[option]) self.form_fields[option].set_value(self.options[option])
except KeyError: 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): def read_form_item(self, option):
""" """

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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