summaryrefslogtreecommitdiff
path: root/tests/test_util.py
diff options
context:
space:
mode:
authorTim Hatch <tim@timhatch.com>2014-11-06 19:41:33 -0800
committerTim Hatch <tim@timhatch.com>2014-11-06 19:41:33 -0800
commit348b35f182e85f950e65a68d69d0f130912e8370 (patch)
treea527e8d5e04e9b5503bc88341135d1f916e29a9b /tests/test_util.py
parentc863ac19ce4d591b93be8b36cb69b04422c8dc9f (diff)
downloadpygments-348b35f182e85f950e65a68d69d0f130912e8370.tar.gz
Add 'duplicates_removed' function (for *_builtins.py generation).
Diffstat (limited to 'tests/test_util.py')
-rw-r--r--tests/test_util.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_util.py b/tests/test_util.py
index 7bf03409..7fbbba2d 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -141,3 +141,19 @@ class UtilTest(unittest.TestCase):
exec(output, d)
self.assertTrue(isinstance(d['var'], tuple))
self.assertEqual(('cat', 'dog'), d['var'])
+
+ def test_duplicates_removed_seq_types(self):
+ # tuple
+ x = util.duplicates_removed(('a', 'a', 'b'))
+ self.assertSequenceEqual(('a', 'b'), x)
+ # list
+ x = util.duplicates_removed(['a', 'a', 'b'])
+ self.assertSequenceEqual(('a', 'b'), x)
+ # iterator
+ x = util.duplicates_removed(iter(('a', 'a', 'b')))
+ self.assertSequenceEqual(('a', 'b'), x)
+
+ def test_duplicates_removed_nonconsecutive(self):
+ # keeps first
+ x = util.duplicates_removed(('a', 'b', 'a'))
+ self.assertSequenceEqual(('a', 'b'), x)