~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Gordon Tyler
  • Date: 2011-01-20 04:44:14 UTC
  • mto: This revision was merged to the branch mainline in revision 5632.
  • Revision ID: gordon@doxxx.net-20110120044414-x8vislng3ukcfr1d
Simplified mergetools module down to functions which deal with command lines -- no MergeTool class.

Show diffs side-by-side

added added

removed removed

Lines of Context:
958
958
        self.assertIs(None, change_editor)
959
959
 
960
960
    def test_get_merge_tools(self):
961
 
        def cmptool(a, b):
962
 
            return cmp(a.name, b.name)
963
961
        conf = self._get_sample_config()
964
 
        tools = sorted(conf.get_merge_tools(), cmptool)
 
962
        tools = conf.get_merge_tools()
965
963
        self.log(repr(tools))
966
 
        tools = [(tool.name, tool.command_line) for tool in tools]
967
 
        self.assertEqual([
968
 
            ('funkytool', 'funkytool "arg with spaces" {this_temp}'),
969
 
            ('sometool', 'sometool {base} {this} {other} -o {result}'),
970
 
            ],
 
964
        self.assertEqual(
 
965
            {u'funkytool' : u'funkytool "arg with spaces" {this_temp}',
 
966
            u'sometool' : u'sometool {base} {this} {other} -o {result}'},
971
967
            tools)
972
968
 
973
 
    def test_get_default_merge_tool(self):
974
 
        conf = self._get_sample_config()
975
 
        self.assertEqual('sometool', conf.get_default_merge_tool())
976
 
 
977
 
    def test_get_default_merge_tool_empty(self):
 
969
    def test_get_merge_tools_empty(self):
978
970
        conf = self._get_empty_config()
979
 
        tool = conf.get_default_merge_tool()
980
 
        self.assertIs(tool, None)
 
971
        tools = conf.get_merge_tools()
 
972
        self.assertEqual({}, tools)
981
973
 
982
974
    def test_find_merge_tool(self):
983
975
        conf = self._get_sample_config()
984
 
        tool = conf.find_merge_tool('sometool')
985
 
        self.assertIsNot(tool, None)
986
 
        self.assertEqual('sometool', tool.name)
987
 
        self.assertEqual('sometool {base} {this} {other} -o {result}',
988
 
                         tool.command_line)
 
976
        cmdline = conf.find_merge_tool('sometool')
 
977
        self.assertEqual('sometool {base} {this} {other} -o {result}', cmdline)
989
978
 
990
979
    def test_find_merge_tool_not_found(self):
991
980
        conf = self._get_sample_config()
992
 
        tool = conf.find_merge_tool('DOES NOT EXIST')
993
 
        self.assertIs(tool, None)
 
981
        cmdline = conf.find_merge_tool('DOES NOT EXIST')
 
982
        self.assertIs(cmdline, None)
994
983
 
995
984
    def test_find_merge_tool_known(self):
996
985
        conf = self._get_empty_config()
997
 
        tool = conf.find_merge_tool('kdiff3')
998
 
        self.assertIsNot(tool, None)
 
986
        cmdline = conf.find_merge_tool('kdiff3')
 
987
        self.assertEquals('kdiff3 {base} {this} {other} -o {result}', cmdline)
999
988
        
1000
989
    def test_find_merge_tool_override_known(self):
1001
990
        conf = self._get_empty_config()
1002
991
        conf.set_user_option('bzr.mergetool.kdiff3', 'kdiff3 blah')
1003
 
        tool = conf.find_merge_tool('kdiff3')
1004
 
        self.assertIsNot(tool, None)
1005
 
        self.assertEqual('kdiff3', tool.name)
1006
 
        self.assertEqual('kdiff3 blah', tool.command_line)
 
992
        cmdline = conf.find_merge_tool('kdiff3')
 
993
        self.assertEqual('kdiff3 blah', cmdline)
1007
994
 
1008
995
 
1009
996
class TestGlobalConfigSavingOptions(tests.TestCaseInTempDir):