26def touch(fieldName, verbose=True):
27 TestHelper.getInstance().getChangeSet().setFieldValue(fieldName,
None, verbose=verbose)
40 changeSet = TestHelper.getInstance().getChangeSet()
41 for key
in fieldValueDict:
42 changeSet.setFieldValue(key, fieldValueDict[key], verbose=verbose)
57def varyValues(function, funcParams, fieldDict, parentChangeSet=None, verbose=True):
58 if not parentChangeSet:
59 parentChangeSet = TestHelper.getInstance().getChangeSet()
62 if len(fieldDict) == 0:
68 fieldName, fieldValues = fieldDict.popitem()
69 field = Base.getTestCaseContext().field(fieldName)
74 fieldValues = list(field.items())
76 changeSet =
TestHelper().getInstance().getChangeSet()
79 for fieldValue
in fieldValues:
80 changeSet.setFieldValue(fieldName, fieldValue, verbose=verbose)
81 varyValues(function, funcParams, fieldDict, changeSet, verbose)
85 fieldDict[fieldName] = fieldValues
96 if not Base.getTestCaseContext().hasField(fieldName):
97 raise Exception(
"Field %s not found in current test's context!" % (fieldName))
98 field = Base.getTestCaseContext().field(fieldName)
99 if field.type
in (
"String",
"Enum"):
100 return field.stringValue()
101 elif field.type ==
"Bool":
102 return field.boolValue()
103 elif field.type ==
"Integer":
104 return field.intValue()
105 elif field.type ==
"Float":
106 return field.floatValue()
107 elif field.type ==
"Double":
108 return field.doubleValue()
109 elif "Vector6" in field.type:
110 return field.stringValue()
111 elif field.type
in (
"Vector2",
"Vector3",
"Vector4",
"Plane",
"Rotation"):
112 return field.vectorValue()
113 elif field.type
in (
"Matrix"):
114 return field.matrixValue()
115 elif field.type
in (
"Color"):
116 return field.colorValue()
117 elif field.type ==
"Image":
119 elif "MLBase" in field.type:
120 return field.object()
136 TestHelper.getInstance().getChangeSet().setFieldValue(fieldName, fieldValue, verbose=verbose)
151 TestHelper.getInstance().getChangeSet().updateFieldValue(fieldName, fieldValue, verbose=verbose)
166 testCase = fieldValueTestCaseSet.get(testCaseName)
167 testCase.applyParameterization(TestHelper.getInstance().getChangeSet(), verbose=verbose)
168 if not testCase.verifyExpectedResults(verbose=verbose):
169 Logging.error(
"Failed to verify expected results.", depth=1)
Singleton for important helper facilities for the different tests.
getValue(fieldName)
Get value of the given field.
varyValues(function, funcParams, fieldDict, parentChangeSet=None, verbose=True)
Set field values and for each combination call the given function with the given parameters.
setValues(fieldValueDict, verbose=True)
Set field values to the given values.
setValue(fieldName, fieldValue, verbose=True)
Set value of the given field.
touch(fieldName, verbose=True)
Touch the given field.
updateValue(fieldName, fieldValue, verbose=True)
Update value of the given field.
runFieldValueTestCase(fieldValueTestCaseSet, testCaseName, verbose=True)
Run a field-value test case.