33 def touch (fieldName, verbose=True):
34 TestHelper.getInstance().getChangeSet().
setFieldValue(fieldName,
None, verbose=verbose)
44 changeSet = TestHelper.getInstance().getChangeSet()
45 for key
in fieldValueDict:
46 changeSet.setFieldValue(key, fieldValueDict[key], verbose=verbose)
58 def varyValues (function, funcParams, fieldDict, parentChangeSet=None, verbose=True):
59 if not parentChangeSet:
60 parentChangeSet = TestHelper.getInstance().getChangeSet()
63 if len(fieldDict) == 0:
69 fieldName, fieldValues = fieldDict.popitem()
70 field = Base.getTestCaseContext().field(fieldName)
75 fieldValues = list(field.items())
77 changeSet =
TestHelper().getInstance().getChangeSet()
80 for fieldValue
in fieldValues:
81 changeSet.setFieldValue(fieldName, fieldValue, verbose=verbose)
82 varyValues(function, funcParams, fieldDict, changeSet, verbose)
86 fieldDict[fieldName] = fieldValues
94 field = Base.getTestCaseContext().field(fieldName)
96 raise Exception(
"Field (%s) not found in current test's context!" % (fieldName))
97 if field.type
in (
'String',
'Enum'):
98 return field.stringValue()
99 elif field.type ==
'Bool':
100 return field.boolValue()
101 elif field.type ==
'Integer':
102 return field.intValue()
103 elif field.type ==
'Float':
104 return field.floatValue()
105 elif field.type ==
'Double':
106 return field.doubleValue()
107 elif 'Vector6' in field.type:
108 return field.stringValue()
109 elif field.type
in (
'Vector2',
'Vector3',
'Vector4',
'Plane',
'Rotation'):
110 return field.vectorValue()
111 elif field.type
in (
'Matrix'):
112 return field.matrixValue()
113 elif field.type
in (
'Color'):
114 return field.colorValue()
115 elif field.type ==
'Image':
117 elif 'MLBase' in field.type:
118 return field.object()
130 def setValue (fieldName, fieldValue, verbose=True):
131 TestHelper.getInstance().getChangeSet().
setFieldValue(fieldName, fieldValue, verbose=verbose)
143 testCase = fieldValueTestCaseSet.get(testCaseName)
144 testCase.applyParameterization(TestHelper.getInstance().getChangeSet(), verbose=verbose)
145 if not testCase.verifyExpectedResults(verbose=verbose):
146 Logging.error(
"Failed to verify expected results.", depth=1)
Singleton for important helper facilities for the different tests.
def setFieldValue(field, fieldValue)
def touch(fieldName, verbose=True)
Touch the given field.
def setValue(fieldName, fieldValue, verbose=True)
Set value of the given field.
def runFieldValueTestCase(fieldValueTestCaseSet, testCaseName, verbose=True)
Run a field-value test case.
def varyValues(function, funcParams, fieldDict, parentChangeSet=None, verbose=True)
Set field values and for each combination call the given function with the given parameters.
def getValue(fieldName)
Get value of the given field.
def setValues(fieldValueDict, verbose=True)
Set field values to the given values.