Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-more-itertools for openSUSE:Factory checked in at 2022-09-18 17:32:09 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-more-itertools (Old) and /work/SRC/openSUSE:Factory/.python-more-itertools.new.2083 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-more-itertools" Sun Sep 18 17:32:09 2022 rev:20 rq:1004179 version:8.14.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-more-itertools/python-more-itertools.changes 2022-06-17 21:22:54.550786266 +0200 +++ /work/SRC/openSUSE:Factory/.python-more-itertools.new.2083/python-more-itertools.changes 2022-09-18 17:32:12.625768784 +0200 @@ -1,0 +2,11 @@ +Fri Sep 16 18:26:20 UTC 2022 - Dirk M??ller <dmuel...@suse.com> + +- update to 8.14.0: + * :func:`longest_common_prefix` (thanks to nanouasyn) + * :func:`iequals` (thanks to nanouasyn) + * `concurrent.futures.ThreadPoolExecutor` is now imported lazily in :func:`callback_iter`. + * :func:`tail` is now optimized for iterables with a fixed length. + * Some documentation issues were fixed (thanks to pochmann and timgates42) + * This library is now marked for Python 3.10 compatibility in PyPI (thanks to chayim) + +------------------------------------------------------------------- Old: ---- more-itertools-8.13.0.tar.gz New: ---- more-itertools-8.14.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-more-itertools.spec ++++++ --- /var/tmp/diff_new_pack.p73uP8/_old 2022-09-18 17:32:13.101770172 +0200 +++ /var/tmp/diff_new_pack.p73uP8/_new 2022-09-18 17:32:13.105770184 +0200 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python3-%{**}} %define skip_python2 1 Name: python-more-itertools -Version: 8.13.0 +Version: 8.14.0 Release: 0 Summary: More routines for operating on iterables, beyond itertools License: MIT ++++++ more-itertools-8.13.0.tar.gz -> more-itertools-8.14.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/more-itertools-8.13.0/PKG-INFO new/more-itertools-8.14.0/PKG-INFO --- old/more-itertools-8.13.0/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 +++ new/more-itertools-8.14.0/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: more-itertools -Version: 8.13.0 +Version: 8.14.0 Summary: More routines for operating on iterables, beyond itertools Keywords: itertools,iterator,iteration,filter,peek,peekable,collate,chunk,chunked Author-email: Erik Rose <erikr...@grinchcentral.com> @@ -15,6 +15,7 @@ Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy @@ -36,6 +37,7 @@ +------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Grouping | `chunked <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.chunked>`_, | | | `ichunked <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.ichunked>`_, | +| | `chunked_even <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.chunked_even>`_, | | | `sliced <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.sliced>`_, | | | `distribute <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.distribute>`_, | | | `divide <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.divide>`_, | @@ -66,6 +68,7 @@ | Augmenting | `count_cycle <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.count_cycle>`_, | | | `intersperse <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.intersperse>`_, | | | `padded <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.padded>`_, | +| | `repeat_each <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.repeat_each>`_, | | | `mark_ends <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.mark_ends>`_, | | | `repeat_last <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.repeat_last>`_, | | | `adjacent <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.adjacent>`_, | @@ -101,6 +104,7 @@ | | `minmax <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.minmax>`_, | | | `first_true <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.first_true>`_, | | | `quantify <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.quantify>`_ | +| | `iequals <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.iequals>`_ | +------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Selecting | `islice_extended <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.islice_extended>`_, | | | `first <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.first>`_, | @@ -123,6 +127,7 @@ | | `unique_justseen <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.unique_justseen>`_, | | | `duplicates_everseen <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.duplicates_everseen>`_, | | | `duplicates_justseen <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.duplicates_justseen>`_ | +| | `longest_common_prefix <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.longest_common_prefix>`_ | +------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Combinatorics | `distinct_permutations <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.distinct_permutations>`_, | | | `distinct_combinations <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.distinct_combinations>`_, | @@ -158,6 +163,7 @@ | | `make_decorator <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.make_decorator>`_, | | | `SequenceView <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.SequenceView>`_, | | | `time_limited <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.time_limited>`_, | +| | `map_if <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.map_if>`_, | | | `consume <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.consume>`_, | | | `tabulate <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.tabulate>`_, | | | `repeatfunc <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.repeatfunc>`_ | diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/more-itertools-8.13.0/README.rst new/more-itertools-8.14.0/README.rst --- old/more-itertools-8.13.0/README.rst 2022-05-06 16:02:27.359598400 +0200 +++ new/more-itertools-8.14.0/README.rst 2022-08-09 15:50:39.706522700 +0200 @@ -13,6 +13,7 @@ +------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Grouping | `chunked <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.chunked>`_, | | | `ichunked <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.ichunked>`_, | +| | `chunked_even <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.chunked_even>`_, | | | `sliced <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.sliced>`_, | | | `distribute <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.distribute>`_, | | | `divide <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.divide>`_, | @@ -43,6 +44,7 @@ | Augmenting | `count_cycle <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.count_cycle>`_, | | | `intersperse <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.intersperse>`_, | | | `padded <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.padded>`_, | +| | `repeat_each <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.repeat_each>`_, | | | `mark_ends <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.mark_ends>`_, | | | `repeat_last <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.repeat_last>`_, | | | `adjacent <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.adjacent>`_, | @@ -78,6 +80,7 @@ | | `minmax <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.minmax>`_, | | | `first_true <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.first_true>`_, | | | `quantify <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.quantify>`_ | +| | `iequals <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.iequals>`_ | +------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Selecting | `islice_extended <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.islice_extended>`_, | | | `first <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.first>`_, | @@ -100,6 +103,7 @@ | | `unique_justseen <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.unique_justseen>`_, | | | `duplicates_everseen <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.duplicates_everseen>`_, | | | `duplicates_justseen <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.duplicates_justseen>`_ | +| | `longest_common_prefix <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.longest_common_prefix>`_ | +------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Combinatorics | `distinct_permutations <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.distinct_permutations>`_, | | | `distinct_combinations <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.distinct_combinations>`_, | @@ -135,6 +139,7 @@ | | `make_decorator <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.make_decorator>`_, | | | `SequenceView <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.SequenceView>`_, | | | `time_limited <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.time_limited>`_, | +| | `map_if <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.map_if>`_, | | | `consume <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.consume>`_, | | | `tabulate <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.tabulate>`_, | | | `repeatfunc <https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.repeatfunc>`_ | diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/more-itertools-8.13.0/docs/api.rst new/more-itertools-8.14.0/docs/api.rst --- old/more-itertools-8.13.0/docs/api.rst 2022-05-06 16:02:27.365875500 +0200 +++ new/more-itertools-8.14.0/docs/api.rst 2022-08-09 15:43:59.871538400 +0200 @@ -153,6 +153,7 @@ .. function:: minmax(iterable, *[, key, default]) .. autofunction:: minmax(arg1, arg2, *args[, key]) :noindex: +.. autofunction:: iequals ---- @@ -190,6 +191,7 @@ .. autofunction:: unique_in_window .. autofunction:: duplicates_everseen .. autofunction:: duplicates_justseen +.. autofunction:: longest_common_prefix ---- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/more-itertools-8.13.0/docs/versions.rst new/more-itertools-8.14.0/docs/versions.rst --- old/more-itertools-8.13.0/docs/versions.rst 2022-05-06 16:02:27.373623400 +0200 +++ new/more-itertools-8.14.0/docs/versions.rst 2022-08-09 15:49:41.910306700 +0200 @@ -5,6 +5,21 @@ .. automodule:: more_itertools :noindex: +8.14.0 +------ + +* New functions + * :func:`longest_common_prefix` (thanks to nanouasyn) + * :func:`iequals` (thanks to nanouasyn) + +* Changes to existing functions + * `concurrent.futures.ThreadPoolExecutor` is now imported lazily in :func:`callback_iter`. + * :func:`tail` is now optimized for iterables with a fixed length. + +* Other changes + * Some documentation issues were fixed (thanks to pochmann and timgates42) + * This library is now marked for Python 3.10 compatibility in PyPI (thanks to chayim) + 8.13.0 ------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/more-itertools-8.13.0/more_itertools/__init__.py new/more-itertools-8.14.0/more_itertools/__init__.py --- old/more-itertools-8.13.0/more_itertools/__init__.py 2022-05-06 16:02:27.380462600 +0200 +++ new/more-itertools-8.14.0/more_itertools/__init__.py 2022-08-09 15:53:46.644506700 +0200 @@ -3,4 +3,4 @@ from .more import * # noqa from .recipes import * # noqa -__version__ = '8.13.0' +__version__ = '8.14.0' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/more-itertools-8.13.0/more_itertools/more.py new/more-itertools-8.14.0/more_itertools/more.py --- old/more-itertools-8.13.0/more_itertools/more.py 2022-04-18 16:12:48.588682000 +0200 +++ new/more-itertools-8.14.0/more_itertools/more.py 2022-08-09 15:43:59.877477000 +0200 @@ -2,7 +2,6 @@ from collections import Counter, defaultdict, deque, abc from collections.abc import Sequence -from concurrent.futures import ThreadPoolExecutor from functools import partial, reduce, wraps from heapq import merge, heapify, heapreplace, heappop from itertools import ( @@ -36,6 +35,7 @@ powerset, take, unique_everseen, + all_equal, ) __all__ = [ @@ -70,6 +70,7 @@ 'first', 'groupby_transform', 'ichunked', + 'iequals', 'ilen', 'interleave', 'interleave_evenly', @@ -80,6 +81,7 @@ 'iterate', 'last', 'locate', + 'longest_common_prefix', 'lstrip', 'make_decorator', 'map_except', @@ -2337,6 +2339,16 @@ return compress(count(), starmap(pred, it)) +def longest_common_prefix(iterables): + """Yield elements of the longest common prefix amongst given *iterables*. + + >>> ''.join(longest_common_prefix(['abcd', 'abc', 'abf'])) + 'ab' + + """ + return (c[0] for c in takewhile(all_equal, zip(*iterables))) + + def lstrip(iterable, pred): """Yield the items from *iterable*, but strip any from the beginning for which *pred* returns ``True``. @@ -3345,6 +3357,26 @@ chunk.fill_cache() +def iequals(*iterables): + """Return ``True`` if all given *iterables* are equal to each other, + which means that they contain the same elements in the same order. + + The function is useful for comparing iterables of different data types + or iterables that do not support equality checks. + + >>> iequals("abc", ['a', 'b', 'c'], ('a', 'b', 'c'), iter("abc")) + True + + >>> iequals("abc", "acb") + False + + Not to be confused with :func:`all_equals`, which checks whether all + elements of iterable are equal to each other. + + """ + return all(map(all_equal, zip_longest(*iterables, fillvalue=object()))) + + def distinct_combinations(iterable, r): """Yield the distinct combinations of *r* items taken from *iterable*. @@ -3637,7 +3669,10 @@ self._aborted = False self._future = None self._wait_seconds = wait_seconds - self._executor = ThreadPoolExecutor(max_workers=1) + # Lazily import concurrent.future + self._executor = __import__( + 'concurrent.futures' + ).futures.ThreadPoolExecutor(max_workers=1) self._iterator = self._reader() def __enter__(self): @@ -3942,7 +3977,7 @@ n, _ = last(pool, default=(n, None)) - # Python versiosn below 3.8 don't have math.comb + # Python versions below 3.8 don't have math.comb index = 1 for i, j in enumerate(reversed(indexes), start=1): j = n - j diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/more-itertools-8.13.0/more_itertools/more.pyi new/more-itertools-8.14.0/more_itertools/more.pyi --- old/more-itertools-8.13.0/more_itertools/more.pyi 2021-11-04 17:55:44.189013200 +0100 +++ new/more-itertools-8.14.0/more_itertools/more.pyi 2022-08-09 15:43:59.881166500 +0200 @@ -662,3 +662,7 @@ *others: _T, key: Callable[[_T], _SupportsLessThan] ) -> Tuple[_T, _T]: ... +def longest_common_prefix( + iterables: Iterable[Iterable[_T]], +) -> Iterator[_T]: ... +def iequals(*iterables: Iterable[object]) -> bool: ... diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/more-itertools-8.13.0/more_itertools/recipes.py new/more-itertools-8.14.0/more_itertools/recipes.py --- old/more-itertools-8.13.0/more_itertools/recipes.py 2022-04-29 16:09:30.642570000 +0200 +++ new/more-itertools-8.14.0/more_itertools/recipes.py 2022-08-09 15:43:59.884092800 +0200 @@ -11,6 +11,7 @@ import warnings from collections import deque +from collections.abc import Sized from itertools import ( chain, combinations, @@ -106,7 +107,14 @@ ['E', 'F', 'G'] """ - return iter(deque(iterable, maxlen=n)) + # If the given iterable has a length, then we can use islice to get its + # final elements. Note that if the iterable is not actually Iterable, + # either islice or deque will throw a TypeError. This is why we don't + # check if it is Iterable. + if isinstance(iterable, Sized): + yield from islice(iterable, max(0, len(iterable) - n), None) + else: + yield from iter(deque(iterable, maxlen=n)) def consume(iterator, n=None): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/more-itertools-8.13.0/pyproject.toml new/more-itertools-8.14.0/pyproject.toml --- old/more-itertools-8.13.0/pyproject.toml 2022-03-09 20:55:14.103891100 +0100 +++ new/more-itertools-8.14.0/pyproject.toml 2022-08-09 15:43:59.886106300 +0200 @@ -29,6 +29,7 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/more-itertools-8.13.0/setup.cfg new/more-itertools-8.14.0/setup.cfg --- old/more-itertools-8.13.0/setup.cfg 2022-05-06 16:02:27.386688500 +0200 +++ new/more-itertools-8.14.0/setup.cfg 2022-08-09 15:53:46.644978300 +0200 @@ -1,5 +1,5 @@ [bumpversion] -current_version = 8.13.0 +current_version = 8.14.0 commit = True tag = False files = more_itertools/__init__.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/more-itertools-8.13.0/tests/test_more.py new/more-itertools-8.14.0/tests/test_more.py --- old/more-itertools-8.13.0/tests/test_more.py 2022-03-09 20:55:14.107215200 +0100 +++ new/more-itertools-8.14.0/tests/test_more.py 2022-08-09 15:43:59.889434000 +0200 @@ -3218,8 +3218,8 @@ class IsliceExtendedTests(TestCase): def test_all(self): iterable = ['0', '1', '2', '3', '4', '5'] - indexes = list(range(-4, len(iterable) + 4)) + [None] - steps = [1, 2, 3, 4, -1, -2, -3, 4] + indexes = [*range(-4, 10), None] + steps = [1, 2, 3, 4, -1, -2, -3, -4] for slice_args in product(indexes, indexes, steps): with self.subTest(slice_args=slice_args): actual = list(mi.islice_extended(iterable, *slice_args)) @@ -5054,3 +5054,86 @@ def test_nested(self): iterable = [[[1, 2], [1, 2]], [5, 6], [5, 6]] self.assertEqual(list(mi.duplicates_justseen(iterable)), [[5, 6]]) + + +class LongestCommonPrefixTests(TestCase): + def test_basic(self): + iterables = [[1, 2], [1, 2, 3], [1, 2, 4]] + self.assertEqual(list(mi.longest_common_prefix(iterables)), [1, 2]) + + def test_iterators(self): + iterables = iter([iter([1, 2]), iter([1, 2, 3]), iter([1, 2, 4])]) + self.assertEqual(list(mi.longest_common_prefix(iterables)), [1, 2]) + + def test_no_iterables(self): + iterables = [] + self.assertEqual(list(mi.longest_common_prefix(iterables)), []) + + def test_empty_iterables_only(self): + iterables = [[], [], []] + self.assertEqual(list(mi.longest_common_prefix(iterables)), []) + + def test_includes_empty_iterables(self): + iterables = [[1, 2], [1, 2, 3], [1, 2, 4], []] + self.assertEqual(list(mi.longest_common_prefix(iterables)), []) + + def test_non_hashable(self): + # See https://github.com/more-itertools/more-itertools/issues/603 + iterables = [[[1], [2]], [[1], [2], [3]], [[1], [2], [4]]] + self.assertEqual(list(mi.longest_common_prefix(iterables)), [[1], [2]]) + + def test_prefix_contains_elements_of_the_first_iterable(self): + iterables = [[[1], [2]], [[1], [2], [3]], [[1], [2], [4]]] + prefix = list(mi.longest_common_prefix(iterables)) + self.assertIs(prefix[0], iterables[0][0]) + self.assertIs(prefix[1], iterables[0][1]) + self.assertIsNot(prefix[0], iterables[1][0]) + self.assertIsNot(prefix[1], iterables[1][1]) + self.assertIsNot(prefix[0], iterables[2][0]) + self.assertIsNot(prefix[1], iterables[2][1]) + + def test_infinite_iterables(self): + prefix = mi.longest_common_prefix([count(), count()]) + self.assertEqual(next(prefix), 0) + self.assertEqual(next(prefix), 1) + self.assertEqual(next(prefix), 2) + + def test_contains_infinite_iterables(self): + iterables = [[0, 1, 2], count()] + self.assertEqual(list(mi.longest_common_prefix(iterables)), [0, 1, 2]) + + +class IequalsTests(TestCase): + def test_basic(self): + self.assertTrue(mi.iequals("abc", iter("abc"))) + self.assertTrue(mi.iequals(range(3), [0, 1, 2])) + self.assertFalse(mi.iequals("abc", [0, 1, 2])) + + def test_no_iterables(self): + self.assertTrue(mi.iequals()) + + def test_one_iterable(self): + self.assertTrue(mi.iequals("abc")) + + def test_more_than_two_iterable(self): + self.assertTrue(mi.iequals("abc", iter("abc"), ['a', 'b', 'c'])) + self.assertFalse(mi.iequals("abc", iter("abc"), ['a', 'b', 'd'])) + + def test_order_matters(self): + self.assertFalse(mi.iequals("abc", "acb")) + + def test_not_equal_lengths(self): + self.assertFalse(mi.iequals("abc", "ab")) + self.assertFalse(mi.iequals("abc", "bc")) + self.assertFalse(mi.iequals("aaa", "aaaa")) + + def test_empty_iterables(self): + self.assertTrue(mi.iequals([], "")) + + def test_none_is_not_a_sentinel(self): + # See https://stackoverflow.com/a/900444 + self.assertFalse(mi.iequals([1, 2], [1, 2, None])) + self.assertFalse(mi.iequals([1, 2], [None, 1, 2])) + + def test_not_identical_but_equal(self): + self.assertTrue([1, True], [1.0, complex(1, 0)]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/more-itertools-8.13.0/tests/test_recipes.py new/more-itertools-8.14.0/tests/test_recipes.py --- old/more-itertools-8.13.0/tests/test_recipes.py 2022-04-29 16:09:30.661166400 +0200 +++ new/more-itertools-8.14.0/tests/test_recipes.py 2022-08-09 15:43:59.891580000 +0200 @@ -59,21 +59,29 @@ class TailTests(TestCase): """Tests for ``tail()``""" - def test_greater(self): - """Length of iterable is greater than requested tail""" - self.assertEqual(list(mi.tail(3, 'ABCDEFG')), ['E', 'F', 'G']) - - def test_equal(self): - """Length of iterable is equal to the requested tail""" - self.assertEqual( - list(mi.tail(7, 'ABCDEFG')), ['A', 'B', 'C', 'D', 'E', 'F', 'G'] - ) - - def test_less(self): - """Length of iterable is less than requested tail""" - self.assertEqual( - list(mi.tail(8, 'ABCDEFG')), ['A', 'B', 'C', 'D', 'E', 'F', 'G'] - ) + def test_iterator_greater(self): + """Length of iterator is greater than requested tail""" + self.assertEqual(list(mi.tail(3, iter('ABCDEFG'))), list('EFG')) + + def test_iterator_equal(self): + """Length of iterator is equal to the requested tail""" + self.assertEqual(list(mi.tail(7, iter('ABCDEFG'))), list('ABCDEFG')) + + def test_iterator_less(self): + """Length of iterator is less than requested tail""" + self.assertEqual(list(mi.tail(8, iter('ABCDEFG'))), list('ABCDEFG')) + + def test_sized_greater(self): + """Length of sized iterable is greater than requested tail""" + self.assertEqual(list(mi.tail(3, 'ABCDEFG')), list('EFG')) + + def test_sized_equal(self): + """Length of sized iterable is less than requested tail""" + self.assertEqual(list(mi.tail(7, 'ABCDEFG')), list('ABCDEFG')) + + def test_sized_less(self): + """Length of sized iterable is less than requested tail""" + self.assertEqual(list(mi.tail(8, 'ABCDEFG')), list('ABCDEFG')) class ConsumeTests(TestCase):