Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/CuraEngine.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Ha <j.ha@ultimaker.com>2016-08-09 16:28:57 +0300
committerJack Ha <j.ha@ultimaker.com>2016-08-09 16:28:57 +0300
commitf14d67934d54169bfebec519c73d6283eff72f4d (patch)
tree13975a529521cf86a9571c06b1e074ff9d0dae9c /tests/runtest.py
parentfadfaa5a8013efc0100a0c46b599b4f52600ec55 (diff)
Added some mock locals functions in runtests. CURA-1828.
Diffstat (limited to 'tests/runtest.py')
-rw-r--r--tests/runtest.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/runtest.py b/tests/runtest.py
index fdd33200b..2c1c667ac 100644
--- a/tests/runtest.py
+++ b/tests/runtest.py
@@ -23,6 +23,22 @@ import threading
from xml.etree import ElementTree
+# Mock function that occurs in fdmprinter.def.json
+# Use wrapper to provide locals
+def extruderValueWrapper(_locals):
+ def extruderValue(extruder_nr, parameter):
+ return eval(parameter, globals(), _locals)
+ return extruderValue
+
+
+# Mock function that occurs in fdmprinter.def.json
+# Use wrapper to provide locals
+def extruderValuesWrapper(_locals):
+ def extruderValues(parameter):
+ return [eval(parameter, globals(), _locals)]
+ return extruderValues
+
+
## The TestSuite class stores the test results of a single set of tests.
# TestSuite objects are created by the TestResults class.
class TestSuite:
@@ -206,6 +222,7 @@ class Setting:
def _evaluateFunction(self, code, locals):
if not code: #The input was None. This setting value doesn't exist in the JSON.
return None
+
try:
tree = ast.parse(code, "eval")
compiled = compile(code, self._key, "eval")
@@ -224,6 +241,7 @@ class EngineTest:
self._json = json.load(open(json_filename, "r"))
self._locals = {}
self._addAllLocals() #Fills the _locals dictionary.
+ self._addLocalsFunctions() # Add mock functions used in fdmprinter
self._engine = engine_filename
self._models = models
self._settings = {}
@@ -324,6 +342,13 @@ class EngineTest:
for key, data in self._json["settings"].items(): # top level categories
self._addLocals(data["children"]) # the actual settings in each category
+ def _addLocalsFunctions(self):
+ extruderValue = extruderValueWrapper(self._locals)
+ self._locals['extruderValue'] = extruderValue
+
+ extruderValues = extruderValuesWrapper(self._locals)
+ self._locals['extruderValues'] = extruderValues
+
## Adds the default values in a node of the setting tree to the locals.
#
# The results are stored in self._locals, keyed by the setting name.