def test_matchelem(self): #{{{ '''Simple validation with set elements''' template = [itype(int)] a = Set(template) self.assertEqual(a, [1]) self.assertEqual(a, [42]) self.assertNotEqual(a, ['1']) self.assertNotEqual(a, [1.1])
def test_matchkey(self): #{{{ '''Simple validation with eqobj keys''' template = {itype(int): 1} a = Mapping(template) self.assertEqual(a, {1:1}) self.assertEqual(a, {42:1}) self.assertNotEqual(a, {'1':1}) self.assertNotEqual(a, {1:2})
def test_multimatch(self): #{{{ '''Multi key type match''' template = {itype(int): 1, 1: 'hello'} val1 = {242: 1, 1: 'hello'} val2 = {242: 1, 1: 'hello', 2: 1} bad = {242: 1, 1: 'world'} a = Mapping(template) self.assertEqual(a, val1) self.assertEqual(a, val2) self.assertNotEqual(a, bad)
def test_multimatch(self): #{{{ '''Multi key type match''' template = [itype(int), 1] val1 = [242, 1] val2 = [2000, 1, 2] bad1 = [1000, 'a'] bad2 = [] a = Set(template) self.assertEqual(a, val1) self.assertEqual(a, val2) self.assertNotEqual(a, bad2) self.assertNotEqual(a, bad2)
def test_single(self): #{{{ '''Single compare''' a = AllObj(itype(int)) self.assertEqual(a, 1) self.assertNotEqual(a, '1')