~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_library_state.py

  • Committer: Robert Collins
  • Date: 2010-06-25 06:23:08 UTC
  • mto: This revision was merged to the branch mainline in revision 5324.
  • Revision ID: robertc@robertcollins.net-20100625062308-qx287gzfrehs1d21
Restore the original ui_factory when existing BzrLibraryState.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    tests,
23
23
    ui as _mod_ui
24
24
    )
25
 
from bzrlib.tests import fixtures
26
25
 
27
26
 
28
27
# TODO: once sufficiently cleaned up this should be able to be TestCase.
30
29
 
31
30
    def test_ui_is_used(self):
32
31
        ui = _mod_ui.SilentUIFactory()
33
 
        state = library_state.BzrLibraryState(
34
 
            ui=ui, trace=fixtures.RecordingContextManager())
 
32
        state = library_state.BzrLibraryState(ui=ui)
35
33
        orig_ui = _mod_ui.ui_factory
36
34
        state.__enter__()
37
35
        try:
39
37
        finally:
40
38
            state.__exit__(None, None, None)
41
39
            self.assertEqual(orig_ui, _mod_ui.ui_factory)
42
 
 
43
 
    def test_trace_context(self):
44
 
        tracer = fixtures.RecordingContextManager()
45
 
        ui = _mod_ui.SilentUIFactory()
46
 
        state = library_state.BzrLibraryState(ui=ui, trace=tracer)
47
 
        state.__enter__()
48
 
        try:
49
 
            self.assertEqual(['__enter__'], tracer._calls)
50
 
        finally:
51
 
            state.__exit__(None, None, None)
52
 
            self.assertEqual(['__enter__', '__exit__'], tracer._calls)