Option to override user's defaults. Needed for unit testing.

This commit is contained in:
Juan Pablo Caram
2015-10-28 12:00:56 -04:00
parent fb98d6306b
commit 8f5cc7a02d
6 changed files with 50 additions and 22 deletions

View File

@@ -574,7 +574,9 @@ class FCCopy(FCMove):
########################
class FlatCAMDraw(QtCore.QObject):
def __init__(self, app, disabled=False):
assert isinstance(app, FlatCAMApp.App)
assert isinstance(app, FlatCAMApp.App), \
"Expected the app to be a FlatCAMApp.App, got %s" % type(app)
super(FlatCAMDraw, self).__init__()
self.app = app
@@ -767,9 +769,15 @@ class FlatCAMDraw(QtCore.QObject):
self.add_shape(subshape)
return
assert isinstance(shape, DrawToolShape)
assert shape.geo is not None
assert (isinstance(shape.geo, list) and len(shape.geo) > 0) or not isinstance(shape.geo, list)
assert isinstance(shape, DrawToolShape), \
"Expected a DrawToolShape, got %s" % type(shape)
assert shape.geo is not None, \
"Shape object has empty geometry (None)"
assert (isinstance(shape.geo, list) and len(shape.geo) > 0) or \
not isinstance(shape.geo, list), \
"Shape objects has empty geometry ([])"
if isinstance(shape, DrawToolUtilityShape):
self.utility.append(shape)
@@ -825,7 +833,8 @@ class FlatCAMDraw(QtCore.QObject):
:param fcgeometry: FlatCAMGeometry
:return: None
"""
assert isinstance(fcgeometry, Geometry)
assert isinstance(fcgeometry, Geometry), \
"Expected a Geometry, got %s" % type(fcgeometry)
self.deactivate()