def testActionOperators(self): "Test that parseline recognizes and reproduces all of our operators." for ops, ress in self.knownOps: act = actions.parseline(ops, 0) self.assertEqual(str(act), ress) # assert stability of the output. self.assertEqual(str(actions.parseline(ress, 0)), ress)
def testDictAccess(self): "Test that action objects can be accessed like dictionaries." act = actions.parseline("a: reject : log : faillog abc", 0) self.assertEqual(act["reject"], 1) self.assertEqual(act["log"], "") self.assertEqual(act["log"] != None, 1) self.assertEqual(act["faillog"], "abc") # Test default value return for known keys. self.assertEqual(act["quiet"] == None, 1) # Unknown keys should bomb out: self.assertRaises(KeyError, lambda x: act[x], "abc")
def testActRDoesFail(self): "Test ActRule.doesfailall() with basic known values." for s, r in self.knownDoesfails: hi = makehi() ar = actions.parseline(s, 0) self.assertEqual(ar.doesfailall(hi), r)