本文整理汇总了Python中FileTester.FileTester类的典型用法代码示例。如果您正苦于以下问题:Python FileTester类的具体用法?Python FileTester怎么用?Python FileTester使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileTester类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: processResults
def processResults(self, moose_dir, options, output):
FileTester.processResults(self, moose_dir, options, output)
specs = self.specs
if self.getStatus() == self.bucket_fail or specs['skip_checks']:
return output
# Don't Run CSVDiff on Scaled Tests
if options.scaling and specs['scale_refine']:
self.addCaveats('SCALING=True')
self.setStatus(self.bucket_skip.status, self.bucket_skip)
return output
if len(specs['csvdiff']) > 0:
differ = CSVDiffer(specs['test_dir'], specs['csvdiff'], specs['abs_zero'], specs['rel_err'], specs['gold_dir'])
msg = differ.diff()
output += 'Running CSVDiffer.py\n' + msg
if msg != '':
if msg.find("Gold file does not exist!") != -1:
self.setStatus('MISSING GOLD FILE', self.bucket_fail)
elif msg.find("File does not exist!") != -1:
self.setStatus('FILE DOES NOT EXIST', self.bucket_fail)
else:
self.setStatus('CSVDIFF', self.bucket_diff)
return output
self.setStatus(self.success_message, self.bucket_success)
return output
示例2: processResults
def processResults(self, moose_dir, options, output):
FileTester.processResults(self, moose_dir, options, output)
specs = self.specs
if self.isFail() or specs['skip_checks']:
return output
else:
reason = ''
# if still no errors, check other files (just for existence)
for file in self.specs['check_files']:
if not os.path.isfile(os.path.join(self.specs['test_dir'], file)):
reason = 'MISSING FILES'
break
for file in self.specs['check_not_exists']:
if os.path.isfile(os.path.join(self.specs['test_dir'], file)):
reason = 'UNEXPECTED FILES'
break
# if still no errors, check that all the files contain the file_expect_out expression
if reason == '':
if self.specs.isValid('file_expect_out'):
for file in self.specs['check_files']:
fid = open(os.path.join(self.specs['test_dir'], file), 'r')
contents = fid.read()
fid.close()
if not util.checkOutputForPattern(contents, self.specs['file_expect_out']):
reason = 'NO EXPECTED OUT IN FILE'
break
# populate status bucket
if reason != '':
self.setStatus(self.fail, reason)
return output
示例3: processResults
def processResults(self, moose_dir, options, output):
FileTester.processResults(self, moose_dir, options, output)
if self.isFail() or self.specs['skip_checks']:
return output
# Don't Run Exodiff on Scaled Tests
if options.scaling and self.specs['scale_refine']:
return output
# Make sure that all of the Exodiff files are actually available
for file in self.specs['exodiff']:
if not os.path.exists(os.path.join(self.specs['test_dir'], self.specs['gold_dir'], file)):
output += "File Not Found: " + os.path.join(self.specs['test_dir'], self.specs['gold_dir'], file)
self.setStatus(self.fail, 'MISSING GOLD FILE')
break
if not self.isFail():
# Retrieve the commands
commands = self.processResultsCommand(moose_dir, options)
for command in commands:
exo_output = util.runCommand(command)
output += 'Running exodiff: ' + command + '\n' + exo_output + ' ' + ' '.join(self.specs['exodiff_opts'])
if ('different' in exo_output or 'ERROR' in exo_output) and not "Files are the same" in exo_output:
self.setStatus(self.diff, 'EXODIFF')
break
return output
示例4: processResults
def processResults(self, moose_dir, options, output):
FileTester.processResults(self, moose_dir, options, output)
specs = self.specs
if self.isFail() or specs['skip_checks']:
return output
# Don't Run CSVDiff on Scaled Tests
if options.scaling and specs['scale_refine']:
self.addCaveats('SCALING=True')
self.setStatus(self.skip)
return output
if len(specs['csvdiff']) > 0:
differ = CSVDiffer(specs['test_dir'], specs['csvdiff'], specs['abs_zero'], specs['rel_err'], specs['gold_dir'],
specs['override_columns'], specs['override_rel_err'], specs['override_abs_zero'], specs['only_compare_custom'])
msg = differ.diff()
output += 'Running CSVDiffer.py\n' + msg
if msg != '':
if msg.find("Gold file does not exist!") != -1:
self.setStatus(self.fail, 'MISSING GOLD FILE')
elif msg.find("File does not exist!") != -1:
self.setStatus(self.fail, 'FILE DOES NOT EXIST')
else:
self.setStatus(self.diff, 'CSVDIFF')
return output
return output
示例5: checkRunnable
def checkRunnable(self, options):
if ((len(self.specs['override_columns']) != len(self.specs['override_rel_err']))
or (len(self.specs['override_columns']) != len(self.specs['override_abs_zero']))
or (len(self.specs['override_rel_err']) != len(self.specs['override_abs_zero']))):
self.setStatus(self.fail, 'Override inputs not the same length')
return False
return FileTester.checkRunnable(self, options)
示例6: processResults
def processResults(self, moose_dir, options, output):
"""
Perform image diff
"""
# Call base class processResults
FileTester.processResults(self, moose_dir, options, output)
if self.getStatus() == self.bucket_fail:
return output
# Loop through files
specs = self.specs
for filename in specs['imagediff']:
# Error if gold file does not exist
if not os.path.exists(os.path.join(specs['test_dir'], specs['gold_dir'], filename)):
output += "File Not Found: " + os.path.join(specs['test_dir'], specs['gold_dir'], filename)
self.setStatus('MISSING GOLD FILE', self.bucket_fail)
break
# Perform diff
else:
output = 'Running ImageDiffer.py'
gold = os.path.join(specs['test_dir'], specs['gold_dir'], filename)
test = os.path.join(specs['test_dir'], filename)
if sys.platform in ['linux', 'linux2']:
name = 'allowed_linux'
elif sys.platform == 'darwin':
name = 'allowed_darwin'
allowed = specs[name] if specs.isValid(name) else specs['allowed']
differ = ImageDiffer(gold, test, allowed=allowed)
# Update golds (e.g., uncomment this to re-gold for new system or new defaults)
#import shutil; shutil.copy(test, gold)
output += differ.message()
if differ.fail():
self.setStatus('IMAGEDIFF', self.bucket_diff)
break
# If status is still pending, then it is a passing test
if self.getStatus() == self.bucket_pending:
self.setStatus(self.success_message, self.bucket_success)
return output
示例7: validParams
def validParams():
params = FileTester.validParams()
params.addRequiredParam('csvdiff', [], "A list of files to run CSVDiff on.")
params.addParam('override_columns', [], "A list of variable names to customize the CSVDiff tolerances.")
params.addParam('override_rel_err', [], "A list of customized relative error tolerances .")
params.addParam('override_abs_zero', [], "A list of customized absolute zero tolerances.")
params.addParam('only_compare_custom', False, "Only compare (and require) the listed custom columns.")
return params
示例8: validParams
def validParams():
params = FileTester.validParams()
params.addRequiredParam('exodiff', [], "A list of files to exodiff.")
params.addParam('exodiff_opts', [], "Additional arguments to be passed to invocations of exodiff.")
params.addParam('custom_cmp', "Custom comparison file")
params.addParam('use_old_floor', False, "Use Exodiff old floor option")
params.addParam('map', True, "Use geometrical mapping to match up elements. This is usually a good idea because it makes files comparable between runs with Serial and Parallel Mesh.")
return params
示例9: validParams
def validParams():
params = FileTester.validParams()
params.addRequiredParam('input', "The input file to use for this test.")
params.addParam('test_name', "The name of the test - populated automatically")
params.addParam('expect_out', "A regular expression that must occur in the input in order for the test to be considered passing.")
params.addParam('resize_mesh', False, "Resize the input mesh")
params.addParam('off_diagonal', True, "Also test the off-diagonal Jacobian entries")
params.addParam('mesh_size', 1, "Resize the input mesh")
return params
示例10: validParams
def validParams():
params = FileTester.validParams()
params.addRequiredParam('imagediff', [], 'A list of files to compare against the gold.')
params.addParam('allowed', 0.98, "Absolute zero cutoff used in exodiff comparisons.")
params.addParam('allowed_linux', "Absolute zero cuttoff used for linux machines, if not provided 'allowed' is used.")
params.addParam('allowed_darwin', "Absolute zero cuttoff used for Mac OS (Darwin) machines, if not provided 'allowed' is used.")
# We don't want to check for any errors on the screen with this. If there are any real errors then the image test will fail.
params['errors'] = []
params['display_required'] = True
return params
示例11: validParams
def validParams():
params = FileTester.validParams()
params.addRequiredParam('csvdiff', [], "A list of files to run CSVDiff on.")
params.addParam('override_columns', [], "A list of variable names to customize the CSVDiff tolerances.")
params.addParam('override_rel_err', [], "A list of customized relative error tolerances.")
params.addParam('override_abs_zero', [], "A list of customized absolute zero tolerances.")
params.addParam('comparison_file', "Use supplied custom comparison config file.")
params.addParam('rel_err', "A customized relative error tolerances.")
params.addParam('abs_zero', "A customized relative error tolerances.")
return params
示例12: processResults
def processResults(self, moose_dir, options, output):
FileTester.processResults(self, moose_dir, options, output)
specs = self.specs
if self.getStatus() == self.bucket_fail or specs['skip_checks']:
return output
# Don't Run CSVDiff on Scaled Tests
if options.scaling and specs['scale_refine']:
self.setStatus("don't run CSVDiff on Scaled Tests", self.bucket_skip)
return output
if len(specs['csvdiff']) > 0:
differ = CSVDiffer(specs['test_dir'], specs['csvdiff'], specs['abs_zero'], specs['rel_err'])
msg = differ.diff()
output += 'Running CSVDiffer.py\n' + msg
if msg != '':
self.setStatus('CSVDIFF', self.bucket_diff)
return output
self.setStatus(self.success_message, self.bucket_success)
return output
示例13: processResults
def processResults(self, moose_dir, options, output):
FileTester.processResults(self, moose_dir, options, output)
if self.getStatus() == self.bucket_fail or self.specs['skip_checks']:
return output
# Don't Run Exodiff on Scaled Tests
if options.scaling and self.specs['scale_refine']:
self.success_message = "SCALED"
self.setStatus(self.getSuccessMessage(), self.bucket_success)
return output
# Make sure that all of the Exodiff files are actually available
for file in self.specs['exodiff']:
if not os.path.exists(os.path.join(self.specs['test_dir'], self.specs['gold_dir'], file)):
output += "File Not Found: " + os.path.join(self.specs['test_dir'], self.specs['gold_dir'], file)
self.setStatus('MISSING GOLD FILE', self.bucket_fail)
break
if self.getStatus() != self.bucket_fail:
# Retrieve the commands
commands = self.processResultsCommand(moose_dir, options)
for command in commands:
exo_output = util.runCommand(command)
output += 'Running exodiff: ' + command + '\n' + exo_output + ' ' + ' '.join(self.specs['exodiff_opts'])
if ('different' in exo_output or 'ERROR' in exo_output) and not "Files are the same" in exo_output:
self.setStatus('EXODIFF', self.bucket_diff)
break
# If status is still pending, then it is a passing test
if self.getStatus() == self.bucket_pending:
self.setStatus(self.success_message, self.bucket_success)
return output
示例14: validParams
def validParams():
params = FileTester.validParams()
params.addParam('check_files', [], "A list of files that MUST exist.")
params.addParam('check_not_exists', [], "A list of files that must NOT exist.")
params.addParam('file_expect_out', "A regular expression that must occur in all of the check files in order for the test to be considered passing.")
return params
示例15: __init__
def __init__(self, name, params):
FileTester.__init__(self, name, params)
# Make sure that either input or command is supplied
if not (params.isValid('check_files') or params.isValid('check_not_exists')):
raise Exception('Either "check_files" or "check_not_exists" must be supplied for a CheckFiles test')