Tracking which group the grouper _should_ be on using an incrementing integer seems to work pretty well.
In additional to the tests in `test_itertools.py`, I've gotten the following tests to pass:
class TestGroupBy(unittest.TestCase):
def test_unpacking(self):
iterable = 'AAAAABBBBB'
(_, a), (_, b) = groupby(iterable)
self.assertEqual(list(a), [])
self.assertEqual(list(b), [])
def test_weird_iterating(self):
g = groupby('AAAABBBBAAAAABBBBB')
_, a = next(g)
_, b = next(g)
_, aa = next(g)
self.assertEqual(list(a), [])
self.assertEqual(list(b), [])
self.assertEqual(list(aa), list('AAAAA'))
If I was to submit this as a PR,
1. where would I want to add these tests?
2. should I update the documentation for the "equivalent" python version to match exactly? |