in tools/plisttool/plisttool_unittest.py [0:0]
def test_nonexistant_variable_substitution(self):
plist1 = {
'FooBraces': 'A-${NOT_A_VARIABLE}-B'
}
with self.assertRaisesRegex(
plisttool.PlistToolError,
re.escape(plisttool.UNKNOWN_SUBSTITUTATION_REFERENCE_MSG % (
_testing_target, '${NOT_A_VARIABLE}', 'FooBraces',
'A-${NOT_A_VARIABLE}-B'))):
_plisttool_result({'plists': [plist1]})
plist2 = {
'FooParens': '$(NOT_A_VARIABLE)'
}
with self.assertRaisesRegex(
plisttool.PlistToolError,
re.escape(plisttool.UNKNOWN_SUBSTITUTATION_REFERENCE_MSG % (
_testing_target, '$(NOT_A_VARIABLE)', 'FooParens',
'$(NOT_A_VARIABLE)'))):
_plisttool_result({'plists': [plist2]})
# Nested dict, will include the keypath.
plist3 = {
'Key1': {
'Key2': 'foo.bar.$(PRODUCT_NAME:rfc1034identifier)'
}
}
with self.assertRaisesRegex(
plisttool.PlistToolError,
re.escape(plisttool.UNKNOWN_SUBSTITUTATION_REFERENCE_MSG % (
_testing_target, '$(PRODUCT_NAME:rfc1034identifier)',
'Key1:Key2', 'foo.bar.$(PRODUCT_NAME:rfc1034identifier)'))):
_plisttool_result({'plists': [plist3]})
# Array, will include the keypath.
plist3 = {
'Key': [
'this one is ok',
'foo.bar.$(PRODUCT_NAME:rfc1034identifier)'
]
}
with self.assertRaisesRegex(
plisttool.PlistToolError,
re.escape(plisttool.UNKNOWN_SUBSTITUTATION_REFERENCE_MSG % (
_testing_target, '$(PRODUCT_NAME:rfc1034identifier)',
'Key[1]', 'foo.bar.$(PRODUCT_NAME:rfc1034identifier)'))):
_plisttool_result({'plists': [plist3]})