def test__run_editor_EACCES(self):
        """If running a configured editor raises EACESS, the user is warned."""
        self.overrideEnv('BZR_EDITOR', 'eacces.py')
        f = file('eacces.py', 'wb')
        f.write('# Not a real editor')
        f.close()
        # Make the fake editor unreadable (and unexecutable)
        os.chmod('eacces.py', 0)
        # Set $EDITOR so that _run_editor will terminate before trying real
        # editors.
        self.overrideEnv('EDITOR', self.make_do_nothing_editor())
        # Call _run_editor, capturing mutter.warning calls.
        warnings = []

        def warning(*args):
            if len(args) > 1:
                warnings.append(args[0] % args[1:])
            else:
                warnings.append(args[0])

        _warning = trace.warning
        trace.warning = warning
        try:
            msgeditor._run_editor('')
        finally:
            trace.warning = _warning
        self.assertStartsWith(warnings[0],
                              'Could not start editor "eacces.py"')
Esempio n. 2
0
    def test__run_editor_EACCES(self):
        """If running a configured editor raises EACESS, the user is warned."""
        self.overrideEnv("BZR_EDITOR", "eacces.py")
        f = file("eacces.py", "wb")
        f.write("# Not a real editor")
        f.close()
        # Make the fake editor unreadable (and unexecutable)
        os.chmod("eacces.py", 0)
        # Set $EDITOR so that _run_editor will terminate before trying real
        # editors.
        self.overrideEnv("EDITOR", self.make_do_nothing_editor())
        # Call _run_editor, capturing mutter.warning calls.
        warnings = []

        def warning(*args):
            if len(args) > 1:
                warnings.append(args[0] % args[1:])
            else:
                warnings.append(args[0])

        _warning = trace.warning
        trace.warning = warning
        try:
            msgeditor._run_editor("")
        finally:
            trace.warning = _warning
        self.assertStartsWith(warnings[0], 'Could not start editor "eacces.py"')
Esempio n. 3
0
    def test_parse_editor_name(self):
        """Correctly interpret names with spaces.

        See <https://bugs.launchpad.net/bzr/+bug/220331>
        """
        self.overrideEnv("BZR_EDITOR", '"%s"' % self.make_do_nothing_editor("name with spaces"))
        self.assertEqual(True, msgeditor._run_editor("a_filename"))
    def test_parse_editor_name(self):
        """Correctly interpret names with spaces.

        See <https://bugs.launchpad.net/bzr/+bug/220331>
        """
        self.overrideEnv(
            'BZR_EDITOR',
            '"%s"' % self.make_do_nothing_editor('name with spaces'))
        self.assertEqual(True, msgeditor._run_editor('a_filename'))
Esempio n. 5
0
    def test_run_editor(self):
        if sys.platform == "win32":
            f = file('fed.bat', 'w')
            f.write('@rem dummy fed')
            f.close()
            os.environ['BZR_EDITOR'] = 'fed.bat'
        else:
            f = file('fed.sh', 'wb')
            f.write('#!/bin/sh\n')
            f.close()
            os.chmod('fed.sh', 0755)
            os.environ['BZR_EDITOR'] = './fed.sh'

        self.assertEqual(True, msgeditor._run_editor(''),
                         'Unable to run dummy fake editor')
Esempio n. 6
0
    def test_run_editor(self):
        if sys.platform == "win32":
            f = file('fed.bat', 'w')
            f.write('@rem dummy fed')
            f.close()
            os.environ['BZR_EDITOR'] = 'fed.bat'
        else:
            f = file('fed.sh', 'wb')
            f.write('#!/bin/sh\n')
            f.close()
            os.chmod('fed.sh', 0755)
            os.environ['BZR_EDITOR'] = './fed.sh'

        self.assertEqual(True, msgeditor._run_editor(''),
                         'Unable to run dummy fake editor')
 def test_run_editor(self):
     self.overrideEnv('BZR_EDITOR', self.make_do_nothing_editor())
     self.assertEqual(True, msgeditor._run_editor(''),
                      'Unable to run dummy fake editor')
Esempio n. 8
0
 def test_run_editor(self):
     self.overrideEnv("BZR_EDITOR", self.make_do_nothing_editor())
     self.assertEqual(True, msgeditor._run_editor(""), "Unable to run dummy fake editor")