/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/test_lock.py

  • Committer: Robert Collins
  • Date: 2010-05-06 23:41:35 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506234135-yivbzczw1sejxnxc
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now
expected to return an object which can be used to unlock them. This reduces
duplicate code when using cleanups. The previous 'tokens's returned by
``Branch.lock_write`` and ``Repository.lock_write`` are now attributes
on the result of the lock_write. ``repository.RepositoryWriteLockResult``
and ``branch.BranchWriteLockResult`` document this. (Robert Collins)

``log._get_info_for_log_files`` now takes an add_cleanup callable.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2011 Canonical Ltd
 
1
# Copyright (C) 2009 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
17
17
"""Tests for OS Locks."""
18
18
 
19
19
 
20
 
from .. import (
 
20
 
 
21
from bzrlib import (
21
22
    debug,
22
23
    errors,
23
24
    lock,
24
25
    tests,
25
26
    )
26
 
from .scenarios import load_tests_apply_scenarios
27
 
 
28
 
 
29
 
load_tests = load_tests_apply_scenarios
 
27
 
 
28
 
 
29
def load_tests(standard_tests, module, loader):
 
30
    """Parameterize tests for all versions of groupcompress."""
 
31
    scenarios = []
 
32
    for name, write_lock, read_lock in lock._lock_classes:
 
33
        scenarios.append((name, {'write_lock': write_lock,
 
34
                                 'read_lock': read_lock}))
 
35
    suite = loader.suiteClass()
 
36
    result = tests.multiply_tests(standard_tests, scenarios, suite)
 
37
    return result
30
38
 
31
39
 
32
40
class TestOSLock(tests.TestCaseInTempDir):
33
41
 
34
 
    scenarios = [(
35
 
        name, {
36
 
            'write_lock': write_lock,
37
 
            'read_lock': read_lock})
38
 
        for name, write_lock, read_lock in lock._lock_classes]
39
 
 
 
42
    # Set by load_tests
40
43
    read_lock = None
41
44
    write_lock = None
42
45
 
118
121
        finally:
119
122
            w_lock.unlock()
120
123
 
 
124
 
121
125
    def test_temporary_write_lock(self):
122
126
        r_lock = self.read_lock('a-lock-file')
123
127
        try: