def test_init(self): "Check that a ModelCheckRunner instantiates properly" runner = ModelCheckRunner() self.assertEqual([], runner.scripts) self.assertTrue(len(runner._checkers(all=True)) > 0) for c in runner._checkers: self.assertTrue(IModelChecker in c._implements)
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_addScript(self): "Check that a runner handles its script list properly" runner = ModelCheckRunner() expectedScriptCount = 0 for text in self.testScripts: self.assertEquals(expectedScriptCount, len(runner.scripts)) script = ModelScript(text=text) runner.addScript(script) expectedScriptCount += 1 self.assertEquals(expectedScriptCount, len(runner.scripts)) self.assertTrue(script in runner.scripts)
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()