~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_status.py

Add bzrlib.pyutils, which has get_named_object, a wrapper around __import__.

This is used to replace various ad hoc implementations of the same logic,
notably the version used in registry's _LazyObjectGetter which had a bug when
getting a module without also getting a member.  And of course, this new
function has unit tests, unlike the replaced code.

This also adds a KnownHooksRegistry subclass to provide a more natural home for
some other logic.

I'm not thrilled about the name of the new module or the new functions, but it's
hard to think of good names for such generic functionality.

Show diffs side-by-side

added added

removed removed

Lines of Context:
704
704
 
705
705
class TestStatusEncodings(TestCaseWithTransport):
706
706
 
707
 
    def setUp(self):
708
 
        TestCaseWithTransport.setUp(self)
709
 
        self.user_encoding = osutils._cached_user_encoding
710
 
        self.stdout = sys.stdout
711
 
 
712
 
    def tearDown(self):
713
 
        osutils._cached_user_encoding = self.user_encoding
714
 
        sys.stdout = self.stdout
715
 
        TestCaseWithTransport.tearDown(self)
716
 
 
717
707
    def make_uncommitted_tree(self):
718
708
        """Build a branch with uncommitted unicode named changes in the cwd."""
719
709
        working_tree = self.make_branch_and_tree(u'.')
727
717
        return working_tree
728
718
 
729
719
    def test_stdout_ascii(self):
730
 
        sys.stdout = StringIO()
731
 
        osutils._cached_user_encoding = 'ascii'
 
720
        self.overrideAttr(osutils, '_cached_user_encoding', 'ascii')
732
721
        working_tree = self.make_uncommitted_tree()
733
722
        stdout, stderr = self.run_bzr("status")
734
723
 
738
727
""")
739
728
 
740
729
    def test_stdout_latin1(self):
741
 
        sys.stdout = StringIO()
742
 
        osutils._cached_user_encoding = 'latin-1'
 
730
        self.overrideAttr(osutils, '_cached_user_encoding', 'latin-1')
743
731
        working_tree = self.make_uncommitted_tree()
744
732
        stdout, stderr = self.run_bzr('status')
745
733