~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/fixtures.py

  • Committer: Robert Collins
  • Date: 2010-06-26 01:07:16 UTC
  • mto: This revision was merged to the branch mainline in revision 5324.
  • Revision ID: robertc@robertcollins.net-20100626010716-jowzrldm4ntsaki2
Make bzrlib startup use a trace context manager.

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
    else:
83
83
        e = [n for (n, u) in interesting_encodings]
84
84
    return itertools.cycle(iter(e))
 
85
 
 
86
 
 
87
class RecordingContextManager(object):
 
88
    """A context manager that records."""
 
89
 
 
90
    def __init__(self):
 
91
        self._calls = []
 
92
 
 
93
    def __enter__(self):
 
94
        self._calls.append('__enter__')
 
95
        return self # This is bound to the 'as' clause in a with statement.
 
96
 
 
97
    def __exit__(self, exc_type, exc_val, exc_tb):
 
98
        self._calls.append('__exit__')
 
99
        return False # propogate exceptions.