コード例 #1
0
ファイル: cpnose.py プロジェクト: cdeepakroy/CellProfiler
def main(*args):
    '''Run the CellProfiler nose tests'''
    args = list(args)
    import cellprofiler.preferences as cpprefs
    cpprefs.set_headless()
    cpprefs.set_awt_headless(True)
    if '--noguitests' in args:
        args.remove('--noguitests')
        sys.modules['wx'] = MockModule()
        sys.modules['wx.html'] = MockModule()
        import matplotlib
        matplotlib.use('agg')
        with_guitests = False
        wxapp = None
    else:
        with_guitests = True
        import wx
        wxapp = wx.App(False)

    def mock_start_vm(*args, **kwargs):
        raise SkipTest

    if '--nojavatests' in args:
        args.remove('--nojavatests')
        javabridge.start_vm = mock_start_vm

    addplugins = [CPShutdownPlugin()]

    if not "--with-cpshutdown" in args:
        args.append("--with-cpshutdown")
    if '--with-kill-vm' in args:
        args[args.index('--with-kill-vm')] = '--with-javabridge'
    if '--with-javabridge' in args:
        class_path = get_jars()
        args.append('--classpath=%s' % os.pathsep.join(class_path))
        if hasattr(sys, "frozen"):
            from javabridge.noseplugin import JavabridgePlugin
            javabridge_plugin_class = JavabridgePlugin
            addplugins.append(JavabridgePlugin())
        else:
            javabridge_plugin_class = load_entry_point('javabridge',
                                                       'nose.plugins.0.10',
                                                       'javabridge')
        javabridge_plugin_class.extra_jvm_args += get_patcher_args(class_path)
        if "CP_JDWP_PORT" in os.environ:
            javabridge_plugin_class.extra_jvm_args.append(
                ("-agentlib:jdwp=transport=dt_socket,address=127.0.0.1:%s"
                 ",server=y,suspend=n") % os.environ["CP_JDWP_PORT"])
        addplugins.append(javabridge_plugin_class())
        #
        # Run the shutdown plugin before the javabridge plugin when exiting
        #
        CPShutdownPlugin.score = javabridge_plugin_class.score + 1

    addplugins.append(LoadTestsFromXML())

    if len(args) == 0:
        args = ['--testmatch=(?:^)test_.*']

    args += ['--exe']
    if hasattr(sys, "frozen"):
        #
        # Patch nose.core.TestProgram.usage
        #    it will attempt to get usage.txt and it's not worth
        #    the effort to make that work.
        #
        from nose.core import TestProgram
        TestProgram.usage = lambda cls: ""

    nose.main(argv=args, addplugins=addplugins)
コード例 #2
0
ファイル: cpnose.py プロジェクト: jiashunzheng/CellProfiler
def main(*args):
    '''Run the CellProfiler nose tests'''
    args = list(args)
    if '--noguitests' in args:
        args.remove('--noguitests')
        import cellprofiler.preferences as cpprefs
        cpprefs.set_headless()
        sys.modules['wx'] = MockModule()
        sys.modules['wx.html'] = MockModule()
        import matplotlib
        matplotlib.use('agg')
        with_guitests = False
    else:
        with_guitests = True

    def mock_start_vm(*args, **kwargs):
        raise SkipTest
    
    if '--nojavatests' in args:
        args.remove('--nojavatests')
        javabridge.start_vm = mock_start_vm
    elif not with_guitests:
        javabridge.activate_awt = mock_start_vm
        javabridge.execute_future_in_main_thread = mock_start_vm
        javabridge.execute_runnable_in_main_thread = mock_start_vm

    addplugins = [CPShutdownPlugin()]

    if not "--with-cpshutdown" in args:
        args.append("--with-cpshutdown")
    if '--with-kill-vm' in args:
        args[args.index('--with-kill-vm')] = '--with-javabridge'
    if '--with-javabridge' in args:
        class_path = get_jars()
        args.append('--classpath=%s' % os.pathsep.join(class_path))
        if hasattr(sys, "frozen"):
            from javabridge.noseplugin import JavabridgePlugin
            javabridge_plugin_class = JavabridgePlugin
            addplugins.append(JavabridgePlugin())
        else:
            javabridge_plugin_class = load_entry_point(
                'javabridge', 'nose.plugins.0.10', 'javabridge')
        javabridge_plugin_class.extra_jvm_args += get_patcher_args(class_path)
        if "CP_JDWP_PORT" in os.environ:
            javabridge_plugin_class.extra_jvm_args.append(
                ("-agentlib:jdwp=transport=dt_socket,address=127.0.0.1:%s"
                 ",server=y,suspend=n") % os.environ["CP_JDWP_PORT"])
        addplugins.append(javabridge_plugin_class())
        #
        # Run the shutdown plugin before the javabridge plugin when exiting
        #
        CPShutdownPlugin.score = javabridge_plugin_class.score + 1
        
    addplugins.append(LoadTestsFromXML())

    if len(args) == 0:
        args = ['--testmatch=(?:^)test_.*']

    args += ['--exe']
    if hasattr(sys, "frozen"):
        #
        # Patch nose.core.TestProgram.usage
        #    it will attempt to get usage.txt and it's not worth
        #    the effort to make that work.
        #
        from nose.core import TestProgram
        TestProgram.usage = lambda cls: ""
    
    nose.main(argv=args, addplugins=addplugins)
コード例 #3
0
jar_directory = get_path_to_jars()
jar_paths = [os.path.join(jar_directory, jarfile) 
             for jarfile in get_cellprofiler_jars()]
class_path = os.pathsep.join(jar_paths)

addplugins = [CPShutdownPlugin()]

if not "--with-cpshutdown" in sys.argv:
    sys.argv.append("--with-cpshutdown")
if '--with-kill-vm' in sys.argv:
    sys.argv[sys.argv.index('--with-kill-vm')] = '--with-javabridge'
if '--with-javabridge' in sys.argv:
    javabridge_plugin_class = load_entry_point(
        'javabridge', 'nose.plugins.0.10', 'javabridge')
    javabridge_plugin_class.extra_jvm_args += get_patcher_args(jar_paths)
    if "CP_JDWP_PORT" in os.environ:
        javabridge_plugin_class.extra_jvm_args.append(
            ("-agentlib:jdwp=transport=dt_socket,address=127.0.0.1:%s"
             ",server=y,suspend=n") % os.environ["CP_JDWP_PORT"])
    addplugins.append(javabridge_plugin_class())
    #
    # Run the shutdown plugin before the javabridge plugin when exiting
    #
    CPShutdownPlugin.score = javabridge_plugin_class.score + 1

if len(sys.argv) == 0:
    args = ['--testmatch=(?:^)test_.*']
else:
    args = sys.argv