import unittest

from dedupe import stable_unique


class HoldoutDedupeTests(unittest.TestCase):
    def test_generator_is_consumed_once(self):
        seen = []

        def values():
            for value in (2, 1, 2):
                seen.append(value)
                yield value

        self.assertEqual(stable_unique(values(), lambda value: value), [2, 1])
        self.assertEqual(seen, [2, 1, 2])
