本文整理汇总了Python中common.logger.Logger.testFailed方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.testFailed方法的具体用法?Python Logger.testFailed怎么用?Python Logger.testFailed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.logger.Logger
的用法示例。
在下文中一共展示了Logger.testFailed方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MatchFiles
# 需要导入模块: from common.logger import Logger [as 别名]
# 或者: from common.logger.Logger import testFailed [as 别名]
def MatchFiles(checkerFile, c1File, targetArch, debuggableMode):
for testCase in checkerFile.testCases:
if testCase.testArch not in [None, targetArch]:
continue
if testCase.forDebuggable != debuggableMode:
continue
# TODO: Currently does not handle multiple occurrences of the same group
# name, e.g. when a pass is run multiple times. It will always try to
# match a check group against the first output group of the same name.
c1Pass = c1File.findPass(testCase.name)
if c1Pass is None:
Logger.fail("Test case \"{}\" not found in the CFG file".format(testCase.name),
testCase.fileName, testCase.startLineNo)
Logger.startTest(testCase.name)
try:
MatchTestCase(testCase, c1Pass)
Logger.testPassed()
except MatchFailedException as e:
lineNo = c1Pass.startLineNo + e.lineNo
if e.assertion.variant == TestAssertion.Variant.Not:
msg = "NOT assertion matched line {}"
else:
msg = "Assertion could not be matched starting from line {}"
msg = msg.format(lineNo)
Logger.testFailed(msg, e.assertion, e.variables)
示例2: matchWords
# 需要导入模块: from common.logger import Logger [as 别名]
# 或者: from common.logger.Logger import testFailed [as 别名]
def matchWords(checkerWord, stringWord, variables, pos):
""" Attempts to match a list of RegexExpressions against a string.
Returns updated variable dictionary if successful and None otherwise.
"""
for expression in checkerWord:
# If `expression` is a variable reference, replace it with the value.
if expression.variant == RegexExpression.Variant.VarRef:
if expression.name in variables:
pattern = re.escape(variables[expression.name])
else:
Logger.testFailed("Missing definition of variable \"{}\"".format(expression.name),
pos.fileName, pos.lineNo)
else:
pattern = expression.pattern
# Match the expression's regex pattern against the remainder of the word.
# Note: re.match will succeed only if matched from the beginning.
match = re.match(pattern, stringWord)
if not match:
return None
# If `expression` was a variable definition, set the variable's value.
if expression.variant == RegexExpression.Variant.VarDef:
if expression.name not in variables:
variables = variables.copyWith(expression.name, stringWord[:match.end()])
else:
Logger.testFailed("Multiple definitions of variable \"{}\"".format(expression.name),
pos.fileName, pos.lineNo)
# Move cursor by deleting the matched characters.
stringWord = stringWord[match.end():]
# Make sure the entire word matched, i.e. `stringWord` is empty.
if stringWord:
return None
return variables
示例3: setVariable
# 需要导入模块: from common.logger import Logger [as 别名]
# 或者: from common.logger.Logger import testFailed [as 别名]
def setVariable(name, value, variables, pos):
if name not in variables:
return variables.copyWith(name, value)
else:
Logger.testFailed("Multiple definitions of variable \"{}\"".format(name), pos, variables)
示例4: getVariable
# 需要导入模块: from common.logger import Logger [as 别名]
# 或者: from common.logger.Logger import testFailed [as 别名]
def getVariable(name, variables, pos):
if name in variables:
return variables[name]
else:
Logger.testFailed("Missing definition of variable \"{}\"".format(name), pos, variables)