annotate tests/comprehensive/test_verify.py @ 426:72e63999722f

tests: make comprehensive tests work properly with nose and run.py
author Augie Fackler <durin42@gmail.com>
date Mon, 15 Jun 2009 12:26:20 -0500
parents 636e9bf5d49c
children 868693631372
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
395
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
1 import os
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
2 import pickle
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
3 import unittest
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
4
426
72e63999722f tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents: 395
diff changeset
5 # wrapped in a try/except because of weirdness in how
72e63999722f tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents: 395
diff changeset
6 # run.py works as compared to nose.
72e63999722f tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents: 395
diff changeset
7 try:
72e63999722f tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents: 395
diff changeset
8 import test_util
72e63999722f tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents: 395
diff changeset
9 except ImportError:
72e63999722f tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents: 395
diff changeset
10 from tests import test_util
395
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
11
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
12 from mercurial import hg
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
13 from mercurial import ui
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
14
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
15 from hgsubversion import svncommands
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
16
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
17 def _do_case(self, name, stupid):
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
18 subdir = test_util.subdir.get(name, '')
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
19 repo = self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid)
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
20 assert len(self.repo) > 0
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
21 for i in repo:
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
22 ctx = repo[i]
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
23 hg.clean(repo, ctx.node(), False)
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
24 self.assertEqual(svncommands.verify(repo.ui, repo), 0)
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
25
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
26 def buildmethod(case, name, stupid):
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
27 m = lambda self: self._do_case(case, stupid)
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
28 m.__name__ = name
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
29 bits = case, stupid and 'stupid' or 'real'
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
30 m.__doc__ = 'Test verify on %s with %s replay.' % bits
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
31 return m
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
32
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
33 attrs = {'_do_case': _do_case}
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
34 fixtures = [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
35 for case in fixtures:
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
36 # this fixture results in an empty repository, don't use it
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
37 if case == 'project_root_not_repo_root.svndump':
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
38 continue
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
39 name = 'test_' + case[:-len('.svndump')]
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
40 attrs[name] = buildmethod(case, name, False)
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
41 name += '_stupid'
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
42 attrs[name] = buildmethod(case, name, True)
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
43
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
44 VerifyTests = type('VerifyTests', (test_util.TestBase,), attrs)
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
45
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
46 def suite():
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
47 all = [unittest.TestLoader().loadTestsFromTestCase(VerifyTests)]
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
48 return unittest.TestSuite(all)