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

  • Committer: Marius Kruger
  • Date: 2010-07-10 21:28:56 UTC
  • mto: (5384.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5385.
  • Revision ID: marius.kruger@enerweb.co.za-20100710212856-uq4ji3go0u5se7hx
* Update documentation
* add NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2010, 2011 Canonical Ltd
 
1
# Copyright (C) 2010 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 BzrLibraryState."""
18
18
 
19
 
import breezy
20
 
from .. import (
 
19
import bzrlib
 
20
from bzrlib import (
21
21
    library_state,
22
22
    tests,
23
23
    ui as _mod_ui
24
24
    )
25
 
from . import fixtures
 
25
from bzrlib.tests import fixtures
26
26
 
27
27
 
28
28
# TODO: once sufficiently cleaned up this should be able to be TestCase.
29
29
class TestLibraryState(tests.TestCaseWithTransport):
30
30
 
31
31
    def test_ui_is_used(self):
32
 
        self.overrideAttr(breezy, '_global_state', None)
33
32
        ui = _mod_ui.SilentUIFactory()
34
33
        state = library_state.BzrLibraryState(
35
34
            ui=ui, trace=fixtures.RecordingContextManager())
42
41
            self.assertEqual(orig_ui, _mod_ui.ui_factory)
43
42
 
44
43
    def test_trace_context(self):
45
 
        self.overrideAttr(breezy, '_global_state', None)
46
44
        tracer = fixtures.RecordingContextManager()
47
45
        ui = _mod_ui.SilentUIFactory()
48
46
        state = library_state.BzrLibraryState(ui=ui, trace=tracer)
52
50
        finally:
53
51
            state.__exit__(None, None, None)
54
52
            self.assertEqual(['__enter__', '__exit__'], tracer._calls)
55
 
 
56
 
    def test_ui_not_specified(self):
57
 
        self.overrideAttr(breezy, '_global_state', None)
58
 
        state = library_state.BzrLibraryState(
59
 
            ui=None, trace=fixtures.RecordingContextManager())
60
 
        orig_ui = _mod_ui.ui_factory
61
 
        state.__enter__()
62
 
        try:
63
 
            self.assertEqual(orig_ui, _mod_ui.ui_factory)
64
 
        finally:
65
 
            state.__exit__(None, None, None)
66
 
            self.assertEqual(orig_ui, _mod_ui.ui_factory)