/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/workingtree_implementations/test_break_lock.py

First attempt to merge .dev and resolve the conflicts (but tests are 
failing)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006 Canonical Ltd
2
2
# Authors:  Robert Collins <robert.collins@canonical.com>
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
20
20
 
21
21
import bzrlib
22
22
import bzrlib.errors as errors
 
23
from bzrlib.tests import TestNotApplicable
23
24
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
24
25
 
25
26
 
51
52
        # if the workingtree isn't locked - and the easiest way
52
53
        # to see if that happened is to lock the repo.
53
54
        self.workingtree.branch.repository.lock_write()
54
 
        bzrlib.ui.ui_factory.stdin = StringIO("y\n")
 
55
        stdin = StringIO("y\n")
 
56
        bzrlib.ui.ui_factory.stdin = stdin
55
57
        try:
56
58
            self.unused_workingtree.break_lock()
57
59
        except NotImplementedError:
58
60
            # workingtree does not support break_lock
59
61
            self.workingtree.branch.repository.unlock()
60
62
            return
61
 
        self.assertRaises(errors.LockBroken, self.workingtree.branch.repository.unlock)
 
63
        remaining = stdin.read()
 
64
        if remaining == 'y\n':
 
65
            raise TestNotApplicable("repository does not physically lock.")
 
66
        self.assertRaises(errors.LockBroken,
 
67
            self.workingtree.branch.repository.unlock)
62
68
 
63
69
    def test_locked(self):
64
70
        # break_lock when locked should
66
72
        bzrlib.ui.ui_factory.stdin = StringIO("y\ny\ny\n")
67
73
        try:
68
74
            self.unused_workingtree.break_lock()
69
 
        except NotImplementedError:
70
 
            # workingtree does not support break_lock
 
75
        except (NotImplementedError, errors.LockActive):
 
76
            # workingtree does not support break_lock,
 
77
            # or does not support breaking a lock held by an alive
 
78
            # object/process.
71
79
            self.workingtree.unlock()
72
80
            return
73
81
        self.assertRaises(errors.LockBroken, self.workingtree.unlock)