~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_diff.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:
29
29
    DiffTree,
30
30
    format_registry as diff_format_registry,
31
31
    )
 
32
from bzrlib.tests import (
 
33
    features,
 
34
    )
32
35
 
33
36
 
34
37
def subst_dates(string):
321
324
        output = self.run_bzr('diff --format=boo', retcode=1)
322
325
        self.assertTrue("BOO!" in output[0])
323
326
 
324
 
 
325
327
class TestCheckoutDiff(TestDiff):
326
328
 
327
329
    def make_example_branch(self):
400
402
        self.assertEndsWith(out, "\n@@ -0,0 +1 @@\n"
401
403
                                 "+baz\n\n")
402
404
 
 
405
    def test_external_diff_options_and_using(self):
 
406
        """Test that the options are passed correctly to an external diff process"""
 
407
        self.requireFeature(features.diff_feature)
 
408
        self.make_example_branch()
 
409
        self.build_tree_contents([('hello', 'Foo\n')])
 
410
        out, err = self.run_bzr('diff --diff-options -i --using diff',
 
411
                                    retcode=1)
 
412
        self.assertEquals("=== modified file 'hello'\n", out)
 
413
        self.assertEquals('', err)
 
414
 
403
415
 
404
416
class TestDiffOutput(DiffBase):
405
417