def run_test(self, compare_dir): cur_dir = os.getcwd() if compare_dir is None: compare_id = None else: compare_id = "" compare_dir = os.path.join(cur_dir, compare_dir, self.test_data['fulldir']) os.chdir(self.run_dir) print "Running test: %s" % self.test_data['fulldir'] self.run_finished = os.path.exists("RunFinished") if os.path.exists(results_filename): if self.run_finished: print "Reading test results from file." res_lines = file(results_filename) for line in res_lines: if len(line.split()) == 2: this_test, this_result = line.split() self.results[this_test] = bool(this_result) else: fn = self.test_data['answer_testing_script'] if RegressionTestRunner is None: print "This installation of yt does not support testing, please update to the branch 'yt'." return clear_registry() handler = logging.FileHandler("testing.log") f = logging.Formatter(ufstring) handler.setFormatter(f) mylog.addHandler(handler) if self.run_finished: if fn != 'None' and fn is not None: if fn.endswith(".py"): fn = fn[:-3] print "Loading module %s" % (fn) f, filename, desc = imp.find_module(fn, ["."]) project = imp.load_module(fn, f, filename, desc) if fn is None or fn == "None": create_test(TestFieldStatistics, "field_stats", tolerance=1e-10) create_test(TestAllProjections, "all_projs", tolerance=1e-10) rtr = RegressionTestRunner("", compare_id, compare_results_path=compare_dir) rtr.run_all_tests() self.results = rtr.passed_tests.copy() mylog.removeHandler(handler) handler.close() os.chdir(cur_dir) self.save_results()
def find_and_initialize_tests(): mapping = {} for f in glob.glob(os.path.join(cwd, "*.py")): clear_registry() iname = os.path.basename(f[:-3]) try: load_tests(iname, cwd) mapping[iname] = registry_entries() #print "Associating %s with" % (iname) #print "\n ".join(registry_entries()) except ImportError: pass return mapping
mapping = {} for f in glob.glob(os.path.join(cwd, "*.py")): clear_registry() iname = os.path.basename(f[:-3]) try: load_tests(iname, cwd) mapping[iname] = registry_entries() #print "Associating %s with" % (iname) #print "\n ".join(registry_entries()) except ImportError: pass return mapping if __name__ == "__main__": clear_registry() mapping = find_and_initialize_tests() test_storage_directory = ytcfg.get("yt", "test_storage_dir") try: my_hash = get_yt_version() except: my_hash = "UNKNOWN%s" % (time.time()) parser = optparse.OptionParser() parser.add_option( "-f", "--parameter-file", dest="parameter_file", default=os.path.join(cwd, "DD0010/moving7_0010"), help="The parameter file value to feed to 'load' to test against") parser.add_option("-l", "--list",