Esempio n. 1
0
def test_suite():
    """Build and return a TestSuite which contains benchmark tests only."""
    testmod_names = [ \
                   'bzrlib.benchmarks.bench_add',
                   'bzrlib.benchmarks.bench_bench',
                   'bzrlib.benchmarks.bench_bundle',
                   'bzrlib.benchmarks.bench_cache_utf8',
                   'bzrlib.benchmarks.bench_checkout',
                   'bzrlib.benchmarks.bench_commit',
                   'bzrlib.benchmarks.bench_dirstate',
                   'bzrlib.benchmarks.bench_info',
                   'bzrlib.benchmarks.bench_inventory',
                   'bzrlib.benchmarks.bench_knit',
                   'bzrlib.benchmarks.bench_log',
                   'bzrlib.benchmarks.bench_pack',
                   'bzrlib.benchmarks.bench_osutils',
                   'bzrlib.benchmarks.bench_rocks',
                   'bzrlib.benchmarks.bench_startup',
                   'bzrlib.benchmarks.bench_status',
                   'bzrlib.benchmarks.bench_transform',
                   'bzrlib.benchmarks.bench_workingtree',
                   'bzrlib.benchmarks.bench_sftp',
                   'bzrlib.benchmarks.bench_xml',
                   ]
    suite = TestLoader().loadTestsFromModuleNames(testmod_names)

    # Load any benchmarks from plugins
    for name, plugin in _mod_plugin.plugins().items():
        if getattr(plugin.module, 'bench_suite', None) is not None:
            suite.addTest(plugin.module.bench_suite())

    return suite
Esempio n. 2
0
def test_suite():
    """Build and return a TestSuite which contains benchmark tests only."""
    testmod_names = [ \
                   'bzrlib.benchmarks.bench_add',
                   'bzrlib.benchmarks.bench_bench',
                   'bzrlib.benchmarks.bench_bundle',
                   'bzrlib.benchmarks.bench_cache_utf8',
                   'bzrlib.benchmarks.bench_checkout',
                   'bzrlib.benchmarks.bench_commit',
                   'bzrlib.benchmarks.bench_dirstate',
                   'bzrlib.benchmarks.bench_info',
                   'bzrlib.benchmarks.bench_inventory',
                   'bzrlib.benchmarks.bench_knit',
                   'bzrlib.benchmarks.bench_log',
                   'bzrlib.benchmarks.bench_pack',
                   'bzrlib.benchmarks.bench_osutils',
                   'bzrlib.benchmarks.bench_rocks',
                   'bzrlib.benchmarks.bench_startup',
                   'bzrlib.benchmarks.bench_status',
                   'bzrlib.benchmarks.bench_transform',
                   'bzrlib.benchmarks.bench_workingtree',
                   'bzrlib.benchmarks.bench_sftp',
                   'bzrlib.benchmarks.bench_xml',
                   ]
    suite = TestLoader().loadTestsFromModuleNames(testmod_names) 

    # Load any benchmarks from plugins
    for name, plugin in _mod_plugin.plugins().items():
        if getattr(plugin.module, 'bench_suite', None) is not None:
            suite.addTest(plugin.module.bench_suite())

    return suite
 def test_plugin_get_path_py_not_pyc(self):
     # first import creates plugin.pyc
     self.setup_plugin()
     self.teardown_plugin()
     plugin.load_from_path(['.'])  # import plugin.pyc
     p = plugin.plugins()['plugin']
     plugin_path = self.test_dir + '/plugin.py'
     self.assertIsSameRealPath(plugin_path, osutils.normpath(p.path()))
Esempio n. 4
0
 def test_plugin_get_path_py_not_pyc(self):
     # first import creates plugin.pyc
     self.setup_plugin()
     self.teardown_plugin()
     plugin.load_from_path(['.']) # import plugin.pyc
     p = plugin.plugins()['plugin']
     plugin_path = self.test_dir + '/plugin.py'
     self.assertIsSameRealPath(plugin_path, osutils.normpath(p.path()))
    def test_load_plugin_tests_gives_load_plugin_tests_result(self):
        source = """
def load_tests(standard_tests, module, loader):
    return 'foo'"""
        self.setup_plugin(source)
        loader = tests.TestUtil.TestLoader()
        p = plugin.plugins()['plugin']
        self.assertEqual('foo', p.load_plugin_tests(loader))
Esempio n. 6
0
    def test_load_plugin_tests_gives_load_plugin_tests_result(self):
        source = """
def load_tests(standard_tests, module, loader):
    return 'foo'"""
        self.setup_plugin(source)
        loader = tests.TestUtil.TestLoader()
        p = plugin.plugins()['plugin']
        self.assertEqual('foo', p.load_plugin_tests(loader))
Esempio n. 7
0
 def test_plugin_get_path_pyc_only(self):
     # first import creates plugin.pyc (or plugin.pyo depending on __debug__)
     self.setup_plugin()
     self.teardown_plugin()
     os.unlink(self.test_dir + '/plugin.py')
     plugin.load_from_path(['.']) # import plugin.pyc (or .pyo)
     p = plugin.plugins()['plugin']
     if __debug__:
         plugin_path = self.test_dir + '/plugin.pyc'
     else:
         plugin_path = self.test_dir + '/plugin.pyo'
     self.assertIsSameRealPath(plugin_path, osutils.normpath(p.path()))
 def test_plugin_get_path_pyc_only(self):
     # first import creates plugin.pyc (or plugin.pyo depending on __debug__)
     self.setup_plugin()
     self.teardown_plugin()
     os.unlink(self.test_dir + '/plugin.py')
     plugin.load_from_path(['.'])  # import plugin.pyc (or .pyo)
     p = plugin.plugins()['plugin']
     if __debug__:
         plugin_path = self.test_dir + '/plugin.pyc'
     else:
         plugin_path = self.test_dir + '/plugin.pyo'
     self.assertIsSameRealPath(plugin_path, osutils.normpath(p.path()))
Esempio n. 9
0
File: plugins.py Progetto: biji/qbzr
 def refresh_view(self):
     """Update the data in the view."""
     plugins = mod_plugin.plugins()
     summary_data = []
     locations_data = []
     for name in sorted(plugins):
         plugin = plugins[name]
         version = format_plugin_version(plugin)
         description = format_plugin_description(plugin)
         directory = osutils.dirname(plugin.path())
         summary_data.append((name, version, description))
         locations_data.append((name, directory))
     self._summary_viewer.setData(summary_data)
     self._locations_viewer.setData(locations_data)
Esempio n. 10
0
 def check_version_info(self, expected, source='', name='plugin'):
     self.setup_plugin(source)
     self.assertEqual(expected, plugin.plugins()[name].version_info())
Esempio n. 11
0
 def check_version_info(self, expected, source='', name='plugin'):
     self.setup_plugin(source)
     self.assertEqual(expected, plugin.plugins()[name].version_info())
Esempio n. 12
0
 def test_no_load_plugin_tests_gives_None_for_load_plugin_tests(self):
     self.setup_plugin()
     loader = tests.TestUtil.TestLoader()
     p = plugin.plugins()['plugin']
     self.assertEqual(None, p.load_plugin_tests(loader))
Esempio n. 13
0
 def test_plugin_appears_in_plugins(self):
     self.setup_plugin()
     self.assertPluginKnown('plugin')
     p = plugin.plugins()['plugin']
     self.assertIsInstance(p, bzrlib.plugin.PlugIn)
     self.assertEqual(p.module, plugins.plugin)
Esempio n. 14
0
 def test_no_test_suite_gives_None_for_test_suite(self):
     self.setup_plugin()
     p = plugin.plugins()['plugin']
     self.assertEqual(None, p.test_suite())
Esempio n. 15
0
 def test_test_suite_gives_test_suite_result(self):
     source = """def test_suite(): return 'foo'"""
     self.setup_plugin(source)
     p = plugin.plugins()['plugin']
     self.assertEqual('foo', p.test_suite())
Esempio n. 16
0
 def test_no_test_suite_gives_None_for_test_suite(self):
     self.setup_plugin()
     p = plugin.plugins()['plugin']
     self.assertEqual(None, p.test_suite())
Esempio n. 17
0
 def test_trivial_plugin_get_path(self):
     self.setup_plugin()
     p = plugin.plugins()['plugin']
     plugin_path = self.test_dir + '/plugin.py'
     self.assertIsSameRealPath(plugin_path, osutils.normpath(p.path()))
Esempio n. 18
0
 def test_trivial_plugin_get_path(self):
     self.setup_plugin()
     p = plugin.plugins()['plugin']
     plugin_path = self.test_dir + '/plugin.py'
     self.assertIsSameRealPath(plugin_path, osutils.normpath(p.path()))
Esempio n. 19
0
 def test_plugin_appears_in_plugins(self):
     self.setup_plugin()
     self.assertPluginKnown('plugin')
     p = plugin.plugins()['plugin']
     self.assertIsInstance(p, bzrlib.plugin.PlugIn)
     self.assertEqual(p.module, plugins.plugin)
Esempio n. 20
0
File: trace.py Progetto: biji/qbzr
def report_exception(exc_info=None,
                     type=MAIN_LOAD_METHOD,
                     window=None,
                     ui_mode=False):
    """Report an exception.

    The error is reported to the console or a message box, depending
    on the type. 
    """

    # We only want one error to show if the user chose Close
    global closing_due_to_error
    # 0.20 special: We check hasattr() first to work around
    # <http://bugs.python.org/issue4230>
    if closing_due_to_error or \
            (hasattr(window, 'closing_due_to_error') and
             window.closing_due_to_error):
        return

    if exc_info is None:
        exc_info = sys.exc_info()

    exc_type, exc_object, exc_tb = exc_info

    # Don't show error for StopException
    if isinstance(exc_object, StopException):
        # Do we maybe want to log this?
        return

    msg_box = ((type == MAIN_LOAD_METHOD and
                (window and window.ui_mode or ui_mode))
               or not type == MAIN_LOAD_METHOD)
    pdb = os.environ.get('BZR_PDB')
    if pdb:
        msg_box = False

    if msg_box:
        err_file = StringIO()
    else:
        err_file = sys.stderr

    # always tell bzr to report it, so it ends up in the log.
    # See https://bugs.launchpad.net/bzr/+bug/785695
    error_type = _bzrlib_report_exception(exc_info, err_file)
    backtrace = traceback.format_exception(*exc_info)
    mutter(''.join(backtrace))

    if (type == MAIN_LOAD_METHOD and window):
        window.ret_code = error_type

    # XXX This is very similar to bzrlib.commands.exception_to_return_code.
    # We shoud get bzr to refactor so that that this is reuseable.
    if pdb:
        # With out this - pyQt shows lot of warnings. see:
        # http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/pyqt4ref.html#using-pyqt-from-the-python-shell
        QtCore.pyqtRemoveInputHook()

        print '**** entering debugger'
        tb = exc_info[2]
        import pdb
        if sys.version_info[:2] < (2, 6):
            # XXX: we want to do
            #    pdb.post_mortem(tb)
            # but because pdb.post_mortem gives bad results for tracebacks
            # from inside generators, we do it manually.
            # (http://bugs.python.org/issue4150, fixed in Python 2.6)

            # Setup pdb on the traceback
            p = pdb.Pdb()
            p.reset()
            p.setup(tb.tb_frame, tb)
            # Point the debugger at the deepest frame of the stack
            p.curindex = len(p.stack) - 1
            p.curframe = p.stack[p.curindex][0]
            # Start the pdb prompt.
            p.print_stack_entry(p.stack[p.curindex])
            p.execRcLines()
            p.cmdloop()
        else:
            pdb.post_mortem(tb)

    close = True
    if msg_box:
        if isinstance(exc_object, errors.LockContention):
            msg_box = create_lockerror_dialog(error_type, window)

        elif error_type == errors.EXIT_INTERNAL_ERROR:
            # this is a copy of bzrlib.trace.report_bug
            # but we seperate the message, and the trace back,
            # and addes a hyper link to the filebug page.
            traceback_file = StringIO()
            _bzrlib_print_exception(exc_info, traceback_file)
            traceback_file.write('\n')
            traceback_file.write('bzr %s on python %s (%s)\n' % \
                               (bzrlib.__version__,
                                bzrlib._format_version_tuple(sys.version_info),
                                sys.platform))
            traceback_file.write('arguments: %r\n' % sys.argv)
            traceback_file.write(
                'encoding: %r, fsenc: %r, lang: %r\n' %
                (osutils.get_user_encoding(), sys.getfilesystemencoding(),
                 os.environ.get('LANG')))
            traceback_file.write("plugins:\n")
            for name, a_plugin in sorted(plugin.plugins().items()):
                traceback_file.write(
                    "  %-20s %s [%s]\n" %
                    (name, a_plugin.path(), a_plugin.__version__))

            msg_box = ErrorReport(gettext("Error"), True,
                                  traceback_file.getvalue(), exc_info, type,
                                  window)
        else:
            msg_box = ErrorReport(gettext("Error"), False, err_file.getvalue(),
                                  exc_info, type, window)
        if window is None:
            icon = QtGui.QIcon()
            icon.addFile(":/bzr-16.png", QtCore.QSize(16, 16))
            icon.addFile(":/bzr-32.png", QtCore.QSize(32, 32))
            icon.addFile(":/bzr-48.png", QtCore.QSize(48, 48))
            msg_box.setWindowIcon(icon)

        msg_box.exec_()

        if not msg_box.result() == QtGui.QMessageBox.Close:
            close = False

    if close:
        if window is None:
            closing_due_to_error = True
            QtCore.QCoreApplication.instance().quit()
        else:
            window.closing_due_to_error = True
            window.close()
    return error_type
Esempio n. 21
0
 def test_test_suite_gives_test_suite_result(self):
     source = """def test_suite(): return 'foo'"""
     self.setup_plugin(source)
     p = plugin.plugins()['plugin']
     self.assertEqual('foo', p.test_suite())
Esempio n. 22
0
 def test_no_load_plugin_tests_gives_None_for_load_plugin_tests(self):
     self.setup_plugin()
     loader = tests.TestUtil.TestLoader()
     p = plugin.plugins()['plugin']
     self.assertEqual(None, p.load_plugin_tests(loader))