예제 #1
0
 def assertList(self, expected, actual):
     '@types: dict, pysonar.ListType'
     self._assertType(ps.ListType, actual)
     actual = actual.elts
     self.assertEqual(len(expected), lists.length(actual), "Size mismatch")
     for i, actual_value in enumerate(actual):
         self.assertEqual(expected[i], _get_value(actual_value),
                      "Different values at index: %s" % i)
예제 #2
0
 def assertDict(self, expected, actual):
     '@types: dict, pysonar.DictType'
     self._assertType(ps.DictType, actual)
     actual = actual.dict
     self.assertEqual(len(expected), lists.length(actual), "Size mismatch")
     for item_pair in actual:
         key, values = item_pair.fst, item_pair.snd
         actual_key = _get_value(key)
         actual_value = _get_value(values[0])
         self.assertEqual(expected.get(actual_key), actual_value,
                      "Value for key '%s': %s != %s, " % (actual_key,
                                              expected.get(actual_key),
                                              actual_value))
예제 #3
0
 def test_length(self):
     """Test length (P04)."""
     self.assertEqual(length([1, 2, 4, 5, 6, 7, 8, 9]), 8)
     self.assertEqual(length(['a', 'b', 'c', 'd', 'e', 'f', 'g']), 7)
     self.assertRaises(TypeError, length, {})