Ejemplo n.º 1
0
    def test_traverse_changed(self):
        calls = []
        op = (lambda dt: calls.append(dt) or str)
        array = Array(ANY)
        transformed = array.traverse(op)

        self.assertIsNot(transformed, array)
        self.assertEqual(transformed, Array(str))
        self.assertEqual(calls, [
            ANY,
        ])
Ejemplo n.º 2
0
    def test_traverse_noop(self):
        calls = []
        op = (lambda dt: calls.append(dt) or dt)
        array = Array(Union(str, int))
        transformed = array.traverse(op)

        self.assertIs(transformed, array)
        self.assertCountEqual(
            calls,
            [
                # Note that it did not recurse into Union(str, int).
                Union(str, int),
            ])