changeset 1057:cd256960b622

comprehensive tests: consolidate stupidity into test_util In other words, remove explicit 'stupid' arguments, set the 'stupid_mode_tests' class variable, and have the metaclass generate non-replay tests.
author Dan Villiom Podlaski Christiansen <dan@cabo.dk>
date Wed, 07 Aug 2013 23:31:57 +0200
parents 0932bb4d8870
children bc71d8c8fde9
files tests/comprehensive/test_rebuildmeta.py tests/comprehensive/test_stupid_pull.py tests/comprehensive/test_updatemeta.py tests/comprehensive/test_verify_and_startrev.py
diffstat 4 files changed, 31 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/tests/comprehensive/test_rebuildmeta.py
+++ b/tests/comprehensive/test_rebuildmeta.py
@@ -30,13 +30,12 @@ expect_youngest_skew = [('file_mixed_wit
 
 
 
-def _do_case(self, name, stupid, single):
+def _do_case(self, name, single):
     subdir = test_util.subdir.get(name, '')
     layout = 'auto'
     if single:
         layout = 'single'
-    repo, repo_path = self.load_and_fetch(name, subdir=subdir, stupid=stupid,
-                                          layout=layout)
+    repo, repo_path = self.load_and_fetch(name, subdir=subdir, layout=layout)
     assert test_util.repolen(self.repo) > 0
     wc2_path = self.wc_path + '_clone'
     u = ui.ui()
@@ -60,7 +59,7 @@ def _do_case(self, name, stupid, single)
         # remove the wrapper
         context.changectx.children = origchildren
 
-    self._run_assertions(name, stupid, single, src, dest, u)
+    self._run_assertions(name, single, src, dest, u)
 
     wc3_path = self.wc_path + '_partial'
     src, dest = test_util.hgclone(u,
@@ -94,10 +93,10 @@ def _do_case(self, name, stupid, single)
         # remove the wrapper
         context.changectx.children = origchildren
 
-    self._run_assertions(name, stupid, single, srcrepo, dest, u)
+    self._run_assertions(name, single, srcrepo, dest, u)
 
 
-def _run_assertions(self, name, stupid, single, src, dest, u):
+def _run_assertions(self, name, single, src, dest, u):
 
     self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')),
                     'no .hg/svn directory in the source!')
@@ -112,7 +111,7 @@ def _run_assertions(self, name, stupid, 
         self.assertTrue(os.path.isfile(dtf), '%r is missing!' % tf)
         old, new = open(stf).read(), open(dtf).read()
         if tf == 'lastpulled' and (name,
-                                   stupid, single) in expect_youngest_skew:
+                                   self.stupid, single) in expect_youngest_skew:
             self.assertNotEqual(old, new,
                                 'rebuildmeta unexpected match on youngest rev!')
             continue
@@ -137,15 +136,11 @@ def _run_assertions(self, name, stupid, 
             self.assertEqual(srcinfo[2], destinfo[2])
 
 
-def buildmethod(case, name, stupid, single):
-    m = lambda self: self._do_case(case, stupid, single)
+def buildmethod(case, name, single):
+    m = lambda self: self._do_case(case, single)
     m.__name__ = name
-    m.__doc__ = ('Test rebuildmeta on %s with %s replay. (%s)' %
-                 (case,
-                  (stupid and 'stupid') or 'real',
-                  (single and 'single') or 'standard',
-                  )
-                 )
+    m.__doc__ = ('Test rebuildmeta on %s (%s)' %
+                 (case, (single and 'single') or 'standard'))
     return m
 
 
@@ -156,16 +151,15 @@ skip = set([
 
 attrs = {'_do_case': _do_case,
          '_run_assertions': _run_assertions,
+         'stupid_mode_tests': True,
          }
 for case in [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]:
     # this fixture results in an empty repository, don't use it
     if case in skip:
         continue
     bname = 'test_' + case[:-len('.svndump')]
-    attrs[bname] = buildmethod(case, bname, False, False)
-    name = bname + '_stupid'
-    attrs[name] = buildmethod(case, name, True, False)
+    attrs[bname] = buildmethod(case, bname, False)
     name = bname + '_single'
-    attrs[name] = buildmethod(case, name, False, True)
+    attrs[name] = buildmethod(case, name, True)
 
 RebuildMetaTests = type('RebuildMetaTests', (test_util.TestBase,), attrs)
--- a/tests/comprehensive/test_stupid_pull.py
+++ b/tests/comprehensive/test_stupid_pull.py
@@ -19,8 +19,7 @@ from hgsubversion import wrappers
 
 def _do_case(self, name, layout):
     subdir = test_util.subdir.get(name, '')
-    repo, repo_path = self.load_and_fetch(name, subdir=subdir, stupid=False,
-                                          layout=layout)
+    repo, repo_path = self.load_and_fetch(name, subdir=subdir, layout=layout)
     assert test_util.repolen(self.repo) > 0, \
         'Repo had no changes, maybe you need to add a subdir entry in test_util?'
     wc2_path = self.wc_path + '_stupid'
--- a/tests/comprehensive/test_updatemeta.py
+++ b/tests/comprehensive/test_updatemeta.py
@@ -22,13 +22,12 @@ from hgsubversion import svnmeta
 
 
 
-def _do_case(self, name, stupid, single):
+def _do_case(self, name, single):
     subdir = test_util.subdir.get(name, '')
     layout = 'auto'
     if single:
         layout = 'single'
-    repo, repo_path = self.load_and_fetch(name, subdir=subdir, stupid=stupid,
-                                          layout=layout)
+    repo, repo_path = self.load_and_fetch(name, subdir=subdir, layout=layout)
     assert test_util.repolen(self.repo) > 0
     wc2_path = self.wc_path + '_clone'
     u = ui.ui()
@@ -53,11 +52,11 @@ def _do_case(self, name, stupid, single)
         # remove the wrapper
         context.changectx.children = origchildren
 
-    self._run_assertions(name, stupid, single, src, dest, u)
+    self._run_assertions(name, single, src, dest, u)
 
 
-def _run_assertions(self, name, stupid, single, src, dest, u):
-    test_rebuildmeta._run_assertions(self, name, stupid, single, src, dest, u)
+def _run_assertions(self, name, single, src, dest, u):
+    test_rebuildmeta._run_assertions(self, name, single, src, dest, u)
 
 
 skip = set([
@@ -67,16 +66,15 @@ skip = set([
 
 attrs = {'_do_case': _do_case,
          '_run_assertions': _run_assertions,
+         'stupid_mode_tests': True,
          }
 for case in [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]:
     # this fixture results in an empty repository, don't use it
     if case in skip:
         continue
     bname = 'test_' + case[:-len('.svndump')]
-    attrs[bname] = test_rebuildmeta.buildmethod(case, bname, False, False)
-    name = bname + '_stupid'
-    attrs[name] = test_rebuildmeta.buildmethod(case, name, True, False)
+    attrs[bname] = test_rebuildmeta.buildmethod(case, bname, False)
     name = bname + '_single'
-    attrs[name] = test_rebuildmeta.buildmethod(case, name, False, True)
+    attrs[name] = test_rebuildmeta.buildmethod(case, name, True)
 
 UpdateMetaTests = type('UpdateMetaTests', (test_util.TestBase,), attrs)
--- a/tests/comprehensive/test_verify_and_startrev.py
+++ b/tests/comprehensive/test_verify_and_startrev.py
@@ -37,10 +37,9 @@ from hgsubversion import verify
     'emptyrepo2.svndump',
 ])
 
-def _do_case(self, name, stupid, layout):
+def _do_case(self, name, layout):
     subdir = test_util.subdir.get(name, '')
-    repo, svnpath = self.load_and_fetch(name, subdir=subdir, stupid=stupid,
-                                        layout=layout)
+    repo, svnpath = self.load_and_fetch(name, subdir=subdir, layout=layout)
     assert test_util.repolen(self.repo) > 0
     for i in repo:
         ctx = repo[i]
@@ -52,7 +51,7 @@ def _do_case(self, name, stupid, layout)
     # check a startrev clone
     if layout == 'single' and name not in _skipshallow:
         self.wc_path += '_shallow'
-        shallowrepo = self.fetch(svnpath, subdir=subdir, stupid=stupid,
+        shallowrepo = self.fetch(svnpath, subdir=subdir,
                                  layout='single', startrev='HEAD')
 
         self.assertEqual(test_util.repolen(shallowrepo), 1,
@@ -85,26 +84,21 @@ def _do_case(self, name, stupid, layout)
             self.assertMultiLineEqual(fulltip[f].data(), shallowtip[f].data())
 
 
-def buildmethod(case, name, stupid, layout):
-    m = lambda self: self._do_case(case, stupid, layout)
+def buildmethod(case, name, layout):
+    m = lambda self: self._do_case(case, layout)
     m.__name__ = name
-    bits = case, stupid and 'stupid' or 'real', layout
-    m.__doc__ = 'Test verify on %s with %s replay. (%s)' % bits
+    m.__doc__ = 'Test verify on %s (%s)' % (case, layout)
     return m
 
-attrs = {'_do_case': _do_case}
+attrs = {'_do_case': _do_case, 'stupid_mode_tests': True}
 fixtures = [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]
 for case in fixtures:
     if case in _skipall:
         continue
     bname = 'test_' + case[:-len('.svndump')]
     if case not in _skipstandard:
-        attrs[bname] = buildmethod(case, bname, False, 'standard')
-        name = bname + '_stupid'
-        attrs[name] = buildmethod(case, name, True, 'standard')
+        attrs[bname] = buildmethod(case, bname, 'standard')
     name = bname + '_single'
-    attrs[name] = buildmethod(case, name, False, 'single')
-    name = bname + '_single_stupid'
-    attrs[name] = buildmethod(case, name, True, 'single')
+    attrs[name] = buildmethod(case, name, 'single')
 
 VerifyTests = type('VerifyTests', (test_util.TestBase,), attrs)