~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lockdir.py

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006-2012, 2016 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
43
43
from bzrlib.tests import (
44
44
    features,
45
45
    TestCase,
 
46
    TestCaseInTempDir,
46
47
    TestCaseWithTransport,
47
48
    )
48
49
 
432
433
        self.assertContainsRe(info_list['time_ago'], r'^\d+ seconds? ago$')
433
434
 
434
435
    def test_lock_without_email(self):
435
 
        global_config = config.GlobalConfig()
 
436
        global_config = config.GlobalStack()
436
437
        # Intentionally has no email address
437
 
        global_config.set_user_option('email', 'User Identity')
 
438
        global_config.set('email', 'User Identity')
438
439
        ld1 = self.get_lock()
439
440
        ld1.create()
440
441
        ld1.lock_write()
474
475
        # now the original caller should succeed in unlocking
475
476
        ld1.unlock()
476
477
        # and there should be nothing left over
477
 
        self.assertEquals([], t.list_dir('test_lock'))
 
478
        self.assertEqual([], t.list_dir('test_lock'))
478
479
 
479
480
    def test_failed_lock_leaves_no_trash(self):
480
481
        # if we fail to acquire the lock, we don't leave pending directories
486
487
        t = self.get_transport().clone('test_lock')
487
488
 
488
489
        def check_dir(a):
489
 
            self.assertEquals(a, t.list_dir('.'))
 
490
            self.assertEqual(a, t.list_dir('.'))
490
491
 
491
492
        check_dir([])
492
493
        # when held, that's all we see
511
512
        lf = LockDir(t, 'test_lock')
512
513
        info = lf.peek()
513
514
        formatted_info = info.to_readable_dict()
514
 
        self.assertEquals(
 
515
        self.assertEqual(
515
516
            dict(user='<unknown>', hostname='<unknown>', pid='<unknown>',
516
517
                time_ago='(unknown)'),
517
518
            formatted_info)
654
655
        self.assertEqual([], self._calls)
655
656
 
656
657
 
657
 
class TestLockHeldInfo(TestCase):
 
658
class TestLockHeldInfo(TestCaseInTempDir):
658
659
    """Can get information about the lock holder, and detect whether they're
659
660
    still alive."""
660
661
 
733
734
            lambda: 'aproperhostname')
734
735
        # This is off by default at present; see the discussion in the bug.
735
736
        # If you change the default, don't forget to update the docs.
736
 
        config.GlobalConfig().set_user_option('locks.steal_dead', True)
 
737
        config.GlobalStack().set('locks.steal_dead', True)
737
738
        # Create a lock pretending to come from a different nonexistent
738
739
        # process on the same machine.
739
740
        l1 = LockDir(self.get_transport(), 'a',