def test_suppress_deprecation_with_warning_filter(self):
     """don't suppress if we already have a filter"""
     warnings.filterwarnings('error', category=Warning)
     self.assertFirstWarning('error', Warning)
     self.assertEqual(1, len(warnings.filters))
     symbol_versioning.suppress_deprecation_warnings(override=False)
     self.assertFirstWarning('error', Warning)
     self.assertEqual(1, len(warnings.filters))
Esempio n. 2
0
 def test_suppress_deprecation_with_warning_filter(self):
     """don't suppress if we already have a filter"""
     warnings.filterwarnings('error', category=Warning)
     self.assertFirstWarning('error', Warning)
     self.assertEqual(1, len(warnings.filters))
     symbol_versioning.suppress_deprecation_warnings(override=False)
     self.assertFirstWarning('error', Warning)
     self.assertEqual(1, len(warnings.filters))
Esempio n. 3
0
def main(argv):
    import bzrlib.ui
    from bzrlib.ui.text import TextUIFactory
    bzrlib.ui.ui_factory = TextUIFactory()
     
    # Is this a final release version? If so, we should suppress warnings
    if bzrlib.version_info[3] == 'final':
        from bzrlib import symbol_versioning
        symbol_versioning.suppress_deprecation_warnings(override=False)
    try:
        argv = [a.decode(bzrlib.user_encoding) for a in argv[1:]]
    except UnicodeDecodeError:
        raise errors.BzrError(("Parameter '%r' is unsupported by the current "
                                                            "encoding." % a))
    ret = run_bzr_catch_errors(argv)
    trace.mutter("return code %d", ret)
    return ret
Esempio n. 4
0
def main(argv):
    import bzrlib.ui
    from bzrlib.ui.text import TextUIFactory
    bzrlib.ui.ui_factory = TextUIFactory()

    # Is this a final release version? If so, we should suppress warnings
    if bzrlib.version_info[3] == 'final':
        from bzrlib import symbol_versioning
        symbol_versioning.suppress_deprecation_warnings(override=False)
    try:
        argv = [a.decode(bzrlib.user_encoding) for a in argv[1:]]
    except UnicodeDecodeError:
        raise errors.BzrError(("Parameter '%r' is unsupported by the current "
                               "encoding." % a))
    ret = run_bzr_catch_errors(argv)
    trace.mutter("return code %d", ret)
    return ret
Esempio n. 5
0
 def test_set_restore_filters(self):
     original_filters = warnings.filters[:]
     symbol_versioning.suppress_deprecation_warnings()()
     self.assertEqual(original_filters, warnings.filters)
Esempio n. 6
0
 def test_suppress_deprecation_warnings(self):
     """suppress_deprecation_warnings sets DeprecationWarning to ignored."""
     symbol_versioning.suppress_deprecation_warnings()
     self.assertFirstWarning('ignore', DeprecationWarning)
 def test_set_restore_filters(self):
     original_filters = warnings.filters[:]
     symbol_versioning.suppress_deprecation_warnings()()
     self.assertEqual(original_filters, warnings.filters)
 def test_suppress_deprecation_warnings(self):
     """suppress_deprecation_warnings sets DeprecationWarning to ignored."""
     symbol_versioning.suppress_deprecation_warnings()
     self.assertFirstWarning('ignore', DeprecationWarning)
Esempio n. 9
0
    def run(self, cmd, to_buffer=True, progress_updates=False):

        if type(cmd) is str:
            argv = shlex.split(cmd)
        else:
            argv = cmd

        if to_buffer:
            output = Output(progress_updates,
                            vim.current.buffer,
                            vim.current.window)
        else:
            output = StringIO()

        olddir = os.getcwd()
        os.chdir(self.root)

        try:
            sys.stdout = output
            sys.stderr = output

            trace.enable_default_logging()
            ui.ui_factory = UI(output)

            # Is this a final release version? If so, we should suppress warnings
            if version_info[3] == 'final':
                from bzrlib import symbol_versioning
                symbol_versioning.suppress_deprecation_warnings(override=False)

            new_argv = []
            try:
                # ensure all arguments are unicode strings
                for arg in argv:
                    if isinstance(arg, unicode):
                        new_argv.append(arg)
                    else:
                        new_argv.append(arg.decode(user_encoding))
            except UnicodeDecodeError:
                raise BzrError("argv should be list of unicode strings.")
            argv = new_argv

            try:
                ret = commands.run_bzr_catch_errors(argv)
            except:
                print >>vim_stderr, StringIO(traceback.format_exc())
                ret = -1

            ui.ui_factory.finish()

            if not to_buffer:
                return output.getvalue()

            output.flush(redraw=False, final=True)

            vim.command("let b:bzrstatus_fileformat = '%s'" %
                        (output.fileformat))

            return ret

        finally:

            for handler in trace._bzr_logger.handlers:
                handler.close()
            if trace._trace_file is not None:
                trace._trace_file.close()
                trace._trace_file = None

            os.chdir(olddir)

            sys.stdout = vim_stdout
            sys.stderr = vim_stderr