~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lockdir.py

  • Committer: Andrew Bennetts
  • Date: 2011-02-07 04:14:29 UTC
  • mfrom: (5535.4.26 fetch-all-tags-309682)
  • mto: This revision was merged to the branch mainline in revision 5648.
  • Revision ID: andrew.bennetts@canonical.com-20110207041429-3kc1blj34rvvxod9
Merge fetch-all-tags-309682.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
16
16
 
17
17
"""Tests for LockDir"""
18
18
 
19
 
from cStringIO import StringIO
20
19
import os
21
20
from threading import Thread, Lock
22
21
import time
34
33
    LockBreakMismatch,
35
34
    LockBroken,
36
35
    LockContention,
37
 
    LockError,
38
36
    LockFailed,
39
37
    LockNotHeld,
40
38
    )
41
39
from bzrlib.lockdir import LockDir
42
 
from bzrlib.tests import (features, TestCaseWithTransport)
 
40
from bzrlib.tests import (
 
41
    features,
 
42
    TestCaseWithTransport,
 
43
    )
43
44
from bzrlib.trace import note
44
45
 
45
46
# These tests sometimes use threads to test the behaviour of lock files with
580
581
                self.prompts.append(('boolean', prompt))
581
582
                return True
582
583
        ui = LoggingUIFactory()
583
 
        orig_factory = bzrlib.ui.ui_factory
584
 
        bzrlib.ui.ui_factory = ui
585
 
        try:
586
 
            ld2.break_lock()
587
 
            self.assertLength(1, ui.prompts)
588
 
            self.assertEqual('boolean', ui.prompts[0][0])
589
 
            self.assertStartsWith(ui.prompts[0][1], 'Break (corrupt LockDir')
590
 
            self.assertRaises(LockBroken, ld.unlock)
591
 
        finally:
592
 
            bzrlib.ui.ui_factory = orig_factory
 
584
        self.overrideAttr(bzrlib.ui, 'ui_factory', ui)
 
585
        ld2.break_lock()
 
586
        self.assertLength(1, ui.prompts)
 
587
        self.assertEqual('boolean', ui.prompts[0][0])
 
588
        self.assertStartsWith(ui.prompts[0][1], 'Break (corrupt LockDir')
 
589
        self.assertRaises(LockBroken, ld.unlock)
593
590
 
594
591
    def test_break_lock_missing_info(self):
595
592
        """break_lock works even if the info file is missing (and tells the UI