def test_other_iterables(self): numbers = [1, 2, 3, 4] cubes_and_squares = ((n, (n**3, n**2)) for n in numbers) self.assertEqual(deep_add(cubes_and_squares), 140) self.assertEqual(deep_add([(1, 2), [3, {4, 5}]]), 15)
def test_deeply_nested_iterables(self): self.assertEqual(deep_add([[1, 2], [3, [4, [[[5]], 6]]]]), 21) self.assertEqual(deep_add([(1, 2), [3, {4, 5}]]), 15)
def test_with_empty_lists(self): self.assertEqual(deep_add([1, [2, 3, []], [], 4]), 10) self.assertEqual(deep_add([]), 0)
def test_other_numeric_types(self): self.assertEqual(deep_add([1.0, [3, 1.5]]), 5.5) self.assertEqual(deep_add([1.0, [3j]]), 1 + 3j)
def test_shallow(self): self.assertEqual(deep_add([1, 2, 3, 4]), 10)