]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
copy babel.util doctests as unit tests
authorAlex Morega <alex@grep.ro>
Sat, 6 Jul 2013 09:34:59 +0000 (11:34 +0200)
committerAlex Morega <alex@grep.ro>
Sat, 6 Jul 2013 12:54:57 +0000 (14:54 +0200)
tests/test_util.py

index 7c72b86139288064c2ea859f4075b7c28a5b0c9e..0c9d349d2ba13ebae3061f2076e872566aded55f 100644 (file)
@@ -16,9 +16,22 @@ import unittest
 
 from babel import util
 
+
+def test_distinct():
+    assert list(util.distinct([1, 2, 1, 3, 4, 4])) == [1, 2, 3, 4]
+    assert list(util.distinct('foobar')) == ['f', 'o', 'b', 'a', 'r']
+
+
+def test_pathmatch():
+    assert util.pathmatch('**.py', 'bar.py')
+    assert util.pathmatch('**.py', 'foo/bar/baz.py')
+    assert not util.pathmatch('**.py', 'templates/index.html')
+    assert util.pathmatch('**/templates/*.html', 'templates/index.html')
+    assert not util.pathmatch('**/templates/*.html', 'templates/foo/bar.html')
+
+
 def suite():
     suite = unittest.TestSuite()
-    suite.addTest(doctest.DocTestSuite(util))
     return suite
 
 if __name__ == '__main__':