From 4d836989720523cd0363927e3e066f56b9dc445c Mon Sep 17 00:00:00 2001 From: yum Date: Sat, 17 Dec 2022 17:26:16 -0800 Subject: Check in `future` package I hit some issues installing Whisper and had to embed this package. I haven't taken the time to deeply understand what's going on. I think that embedded Python follows different rules about resolving module paths than regular system Python. Basically, `future`'s setup.py has a line like `import src`, where `src` is a module inside future (like `future/src/__init__.py`). This doesn't work unless we put that directory on the search path. --- .../tests/test_future/test_common_iterators.py | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Python/Dependencies/future-0.18.2/tests/test_future/test_common_iterators.py (limited to 'Python/Dependencies/future-0.18.2/tests/test_future/test_common_iterators.py') diff --git a/Python/Dependencies/future-0.18.2/tests/test_future/test_common_iterators.py b/Python/Dependencies/future-0.18.2/tests/test_future/test_common_iterators.py new file mode 100644 index 0000000..d274c23 --- /dev/null +++ b/Python/Dependencies/future-0.18.2/tests/test_future/test_common_iterators.py @@ -0,0 +1,39 @@ +from __future__ import absolute_import + +from future.builtins.iterators import * +from future.tests.base import unittest + + +class TestIterators(unittest.TestCase): + def test_range(self): + self.assertNotEqual(type(range(10)), list) + self.assertEqual(sum(range(10)), 45) + self.assertTrue(9 in range(10)) + self.assertEqual(list(range(5)), [0, 1, 2, 3, 4]) + self.assertEqual(repr(range(10)), 'range(0, 10)') + self.assertEqual(repr(range(1, 10)), 'range(1, 10)') + self.assertEqual(repr(range(1, 1)), 'range(1, 1)') + self.assertEqual(repr(range(-10, 10, 2)), 'range(-10, 10, 2)') + + def test_map(self): + def square(x): + return x**2 + self.assertNotEqual(type(map(square, range(10))), list) + self.assertEqual(sum(map(square, range(10))), 285) + self.assertEqual(list(map(square, range(3))), [0, 1, 4]) + + def test_zip(self): + a = range(10) + b = ['a', 'b', 'c'] + self.assertNotEqual(type(zip(a, b)), list) + self.assertEqual(list(zip(a, b)), [(0, 'a'), (1, 'b'), (2, 'c')]) + + def test_filter(self): + a = range(10) + def is_odd(x): + return x % 2 == 1 + self.assertNotEqual(type(filter(is_odd, a)), list) + self.assertEqual(list(filter(is_odd, a)), [1, 3, 5, 7, 9]) + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3