~ubuntu-branches/debian/sid/trac-bzr/sid

« back to all changes in this revision

Viewing changes to .pc/01_test_isolation.diff/tracbzr/tests/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2011-05-01 05:20:09 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20110501052009-s192c1t33hx9f7n4
Tags: 0.4.2+bzr117-1
* New upstream snapshot.
 + Drop 01_test_isolation.diff: Applied upstream.
* Add build dependency on python-bzrlib.tests, required for newer
  versions of bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import os
2
 
import logging
3
 
 
4
 
from os import path
5
 
from shutil import rmtree
6
 
from tempfile import mkdtemp
7
 
 
8
 
from trac import config
9
 
from bzrlib import bzrdir, tests
10
 
 
11
 
from tracbzr import backend
12
 
 
13
 
 
14
 
class DummyComponent(object):
15
 
 
16
 
    def __init__(self):
17
 
        self.log = logging.getLogger('tracbzr.tests')
18
 
        self.log.setLevel(logging.ERROR)
19
 
        self.config = config.Configuration(None)
20
 
 
21
 
 
22
 
class AbstractTracTestCase(tests.TestCase):
23
 
 
24
 
    def setUp(self):
25
 
        super(AbstractTracTestCase, self).setUp()
26
 
        self.root = mkdtemp(prefix='trac+bzr-')
27
 
        self.old_cwd = os.getcwd()
28
 
        os.chdir(self.root)
29
 
 
30
 
    def trac_repo(self, location):
31
 
        param = { 'name': location, 'id': 'trac_bzr_selftest' }
32
 
        return backend.BzrRepository(self.root, param, DummyComponent())
33
 
 
34
 
    def tearDown(self):
35
 
        super(MultiBranchTracTestCase, self).tearDown()
36
 
        os.chdir(self.old_cwd)
37
 
        rmtree(self.root)
38
 
 
39
 
 
40
 
class MultiBranchTracTestCase(AbstractTracTestCase):
41
 
 
42
 
    def setUp(self):
43
 
        super(MultiBranchTracTestCase, self).setUp()
44
 
        dir = bzrdir.BzrDir.create(self.root)
45
 
        self.repo = dir.create_repository()
46
 
        self.treedir = path.join(self.root, 'tree')
47
 
        self.branch = bzrdir.BzrDir.create_branch_convenience(self.treedir,
48
 
            force_new_tree=True)
49
 
        self.tree = self.branch.bzrdir.open_workingtree()
50
 
 
51
 
 
52
 
class SingleBranchTracTestCase(AbstractTracTestCase):
53
 
 
54
 
    def setUp(self):
55
 
        super(SingleBranchTracTestCase, self).setUp()
56
 
        branch = bzrdir.BzrDir.create_branch_convenience(self.root, 
57
 
                        force_new_tree=True)
58
 
        self.tree = branch.bzrdir.open_workingtree()
59
 
        self.repo = branch.repository
60
 
        self.treedir = self.root