def testMethod(obj, name): import pyomo.environ runner = ModelCheckRunner() path = os.path.join(exdir, package, "{0}_{1}.py".format(checkerName, key)) runner.run(script = path, checkers = {package:[checkerName]}) checker = runner._checkers()[0] pc = checker.problemCount lns = checker.linenos checker.resetProblemCount() obj.assertEqual(defs[package][checkerName][key]['problems'], pc) if 'lines' in defs[package][checkerName][key]: obj.assertEqual(sorted(lns), sorted(defs[package][checkerName][key]['lines']))
def test_run_iterative(self): "Check that a runner calls check() on an iterative checker" for text in self.testScripts: runner = ModelCheckRunner() script = ModelScript(text = text) runner.addScript(script) runner.run(checkers = {'mock':['MockIterativeDataChecker', 'MockIterativeTreeChecker']}) for klass in [MockIterativeDataChecker, MockIterativeTreeChecker]: mockChecker = list(filter((lambda c : c.__class__ == klass), runner._checkers()))[0] self.assertTrue(mockChecker.checkCount >= 1) mockChecker.resetCount()