Warning!

Notice: the grml team is migrating from Mercurial to Git.
Please visit git.grml.org instead!

tests: added first unit tests for reposearch
authorMichael Gebetsroither <michael.geb@gmx.at>
Mon Mar 24 15:39:50 2008 +0100 (8 months ago)
changeset 1791945b9335188
manifest1945b9335188
parent 1781a2336bee53a
child 1803f56617d709e
tests: added first unit tests for reposearch
tests/reposearch.py
tests/reposearch_data/git/a/.git/config
tests/reposearch_data/git/b/.git/config
tests/reposearch_data/git/dir/a/.git/config
tests/reposearch_data/git/dir/b/.git/config
tests/reposearch_data/git/dir/no/empty
tests/reposearch_data/git/no/empty
tests/reposearch_tests.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reposearch.py Mon Mar 24 15:39:50 2008 +0100
@@ -0,0 +1,1 @@
+../reposearch
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reposearch_tests.py Mon Mar 24 15:39:50 2008 +0100
@@ -0,0 +1,44 @@
+'''Unittest for reposearch'''
+
+import sys
+import os
+import os.path as op
+
+import reposearch as rs
+import unittest
+
+class Base(unittest.TestCase):
+ dir = "reposearch_data"
+ def inner(self, f):
+ old = op.abspath(os.curdir)
+ os.chdir(self.dir)
+ try:
+ tmp = f()
+ finally:
+ os.chdir(old)
+ return tmp
+
+class Git(Base):
+ def testFlatOuter(self):
+ should = ['reposearch_data/git/a', 'reposearch_data/git/b']
+ curr = list(rs.walkrepos_flat(
+ op.join(self.dir, 'git'), rs.repo_types['git']))
+ self.assertEqual(should, curr)
+ def testFlatInner(self):
+ should = ['git/a', 'git/b']
+ curr = self.inner(lambda: list(rs.walkrepos_flat('git', rs.repo_types['git'])))
+ self.assertEqual(should, curr)
+
+ def testRecOuter(self):
+ should = ['reposearch_data/git/a', 'reposearch_data/git/b',
+ 'reposearch_data/git/dir/a', 'reposearch_data/git/dir/b']
+ curr = list(rs.walkrepos(
+ op.join(self.dir, 'git'), rs.repo_types['git']))
+ self.assertEqual(should, curr)
+ def testRecInner(self):
+ should = ['git/a', 'git/b', 'git/dir/a', 'git/dir/b']
+ curr = self.inner(lambda: list(rs.walkrepos('git', rs.repo_types['git'])))
+ self.assertEqual(should, curr)
+
+if __name__ == "__main__":
+ unittest.main()