Commits

Dan Villiom Podlaski Christiansen  committed cd25696

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.

  • Participants
  • Parent commits 0932bb4

Comments (0)

Files changed (4)

File tests/comprehensive/test_rebuildmeta.py

 
 
 
-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()
         # 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,
         # 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!')
         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
             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
 
 
 
 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)

File tests/comprehensive/test_stupid_pull.py

 
 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'

File tests/comprehensive/test_updatemeta.py

 
 
 
-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()
         # 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([
 
 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)

File tests/comprehensive/test_verify_and_startrev.py

     '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]
     # 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,
             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)