コード例 #1
0
def run_test_suite():
    """Run the Expyriment test suite."""

    import expyriment.design.extras
    import expyriment.stimuli.extras
    import expyriment.io.extras
    import expyriment.misc.extras

    quit_experiment = False
    if not expyriment._active_exp.is_initialized:
        defaults.initialize_delay = 0
        defaults.event_logging = 0
        exp = expyriment.design.Experiment()
        exp.testsuite = True
        expyriment.control.initialize(exp)
        quit_experiment = True
    else:
        exp = expyriment._active_exp

    # make menu and code for test functions
    test_functions = ['', '', '']
    menu = [
        "1) Visual stimulus presentation", "2) Auditory stimulus presentation",
        "3) Font Viewer"
    ]
    for mod, cl in _find_self_tests():
        test_functions.append("rtn = {0}.{1}._self_test(exp)".format(mod, cl))
        menu.append("{0}) {1} test".format(len(test_functions), cl))

    menu.append("{0}) Write protocol".format(len(test_functions) + 1))
    menu.append("{0}) Quit".format(len(test_functions) + 2))
    test_functions.extend(
        ['rtn = _write_protocol(exp, results)', 'go_on=False;rtn=[];'])

    background = stimuli.Canvas(size=[400, 600])
    pict = stimuli.Picture(constants.EXPYRIMENT_LOGO_FILE, position=(0, 200))
    pict.scale(0.5)
    pict.plot(background)

    results = expyriment.get_system_info()

    try:
        import android
        mouse = expyriment.io.Mouse(show_cursor=False)
    except ImportError:
        android = None
        mouse = None

    preselected_item = 0
    go_on = True
    while go_on:
        select = expyriment.io.TextMenu("Test suite",
                                        menu,
                                        width=350,
                                        justification=0,
                                        background_stimulus=background,
                                        mouse=mouse).get(preselected_item)

        if select == 0:
            rtn = _stimulus_timing(exp)
            results["testsuite_visual_timing_todo"] = rtn[0]
            results["testsuite_visual_timing_actual"] = rtn[1]
            results["testsuite_visual_sync_refresh_rate"] = str(rtn[2]) + " Hz"
            results["testsuite_visual_timing_inaccuracy"] = str(rtn[3]) + " ms"
            results["testsuite_visual_timing_delayed"] = str(rtn[4]) + " %"
            results["testsuite_visual_flipping_user"] = rtn[5]
            delay = map(
                lambda x: x[1] - x[0],
                zip(results["testsuite_visual_timing_todo"],
                    results["testsuite_visual_timing_actual"]))
            results["testsuite_visual_timing_delay_histogram"], _ = _histogram(
                delay)
            if ogl is not None and exp.screen.open_gl:
                results["testsuite_visual_opengl_vendor"] = ogl.glGetString(
                    ogl.GL_VENDOR)
                results["testsuite_visual_opengl_renderer"] = ogl.glGetString(
                    ogl.GL_RENDERER)
                results["testsuite_visual_opengl_version"] = ogl.glGetString(
                    ogl.GL_VERSION)
                extensions = ogl.glGetString(ogl.GL_EXTENSIONS).split(" ")
                if extensions[-1] == "":
                    extensions = extensions[:-1]
                results["testsuite_visual_opengl_extensions"] = extensions
            else:
                results["testsuite_visual_opengl_vendor"] = ""
                results["testsuite_visual_opengl_renderer"] = ""
                results["testsuite_visual_opengl_version"] = ""
                results["testsuite_visual_pygame_driver"] = ""
                results["testsuite_visual_opengl_extensions"] = ""
            results[
                "testsuite_visual_pygame_driver"] = pygame.display.get_driver(
                )
            results["testsuite_visual_pygame_screensize"] = exp.screen.size
            preselected_item = select + 1
        elif select == 1:
            results["testsuite_audio_user"] = _audio_playback(exp)
            try:
                results["testsuite_audio_frequency"] = str(
                    pygame.mixer.get_init()[0]) + " Hz"
                results["testsuite_audio_bitdepth"] = str(
                    abs(pygame.mixer.get_init()[1])) + " bit"
                results["testsuite_audio_channels"] = pygame.mixer.get_init(
                )[2]
            except:
                results["testsuite_audio_frequency"] = ""
                results["testsuite_audio_bitdepth"] = ""
                results["testsuite_audio_channels"] = ""
            preselected_item = select + 1
        elif select == 2:
            _font_viewer(exp)
            preselected_item = select + 1
        else:
            exec(test_functions[select])
            results.update(rtn)
            preselected_item = select + 1

    if quit_experiment:
        expyriment.control.end(goodbye_delay=0,
                               goodbye_text="Quitting test suite")
コード例 #2
0
ファイル: cli.py プロジェクト: mutlusun/expyriment
     print "* OpenGL (vsync / blocking)"
     expyriment.control.defaults.open_gl = 2
 elif arg == '3':
     print "* OpenGL (vsync / alternative blocking)"
     expyriment.control.defaults.open_gl = 3
 elif arg == 't':
     print "* No time stamps"
     expyriment.io.defaults.outputfile_time_stamp =\
             False
 elif arg == 'a':
     print "* Auto create subject id"
     expyriment.control.defaults.auto_create_subject_id\
                      = True
 elif arg == "S":
     print "System Info"
     print expyriment.get_system_info(as_string=True)
     sys.exit()
 elif arg == "T":
     print "Run Test Suite"
     expyriment.control.run_test_suite()
     sys.exit()
 elif arg == "B":
     expyriment.show_documentation(2)
     sys.exit()
 elif arg == "A":
     print "Start API Reference Tool"
     expyriment.show_documentation(3)
     sys.exit()
 elif arg == "C":
     create_template()
     sys.exit()
コード例 #3
0
ファイル: _test_suite.py プロジェクト: fladd/expyriment
def run_test_suite():
    """Run the Expyriment test suite."""

    quit_experiment = False
    if not expyriment._active_exp.is_initialized:
        defaults.initialize_delay = 0
        defaults.event_logging = 0
        exp = expyriment.control.initialize()
        quit_experiment = True
    else:
        exp = expyriment._active_exp

    #make menu and code for test functions
    test_functions = ['', '']
    menu = ["1) Visual stimulus presentation",
            "2) Auditory stimulus presentation"]
    for mod, cl in _find_self_tests():
        test_functions.append("rtn = {0}.{1}._self_test(exp)".format(mod, cl))
        menu.append("{0}) {1} test".format(len(test_functions), cl))

    menu.append("{0}) Write protocol".format(len(test_functions) + 1))
    menu.append("{0}) Quit".format(len(test_functions) + 2))
    test_functions.extend(['rtn = _write_protocol(exp, results)',
                            'go_on=False;rtn=[];'])

    background = stimuli.Canvas(size=[400, 600])
    pict = stimuli.Picture(constants.EXPYRIMENT_LOGO_FILE, position=(0, 200))
    pict.scale(0.5)
    pict.plot(background)

    results = expyriment.get_system_info()

    preselected_item = 0
    go_on = True
    while go_on:
        select = expyriment.io.TextMenu(
            "Test suite", menu, width=350, justification=0,
            background_stimulus=background).get(preselected_item)

        if select == 0:
            rtn = _stimulus_timing(exp)
            results["testsuite_visual_timing_todo"] = rtn[0]
            results["testsuite_visual_timing_actual"] = rtn[1]
            results["testsuite_visual_timing_user"] = rtn[2]
            results["testsuite_visual_sync_refresh_rate"] = str(rtn[3]) + " Hz"
            results["testsuite_visual_sync_user"] = rtn[4]
            results["testsuite_visual_flipping_user"] = rtn[5]
            if ogl is not None:
                results["testsuite_visual_opengl_vendor"] = ogl.glGetString(ogl.GL_VENDOR)
                results["testsuite_visual_opengl_renderer"] = ogl.glGetString(ogl.GL_RENDERER)
                results["testsuite_visual_opengl_version"] = ogl.glGetString(ogl.GL_VERSION)
                results["testsuite_visual_pygame_driver"] = pygame.display.get_driver()
                extensions = ogl.glGetString(ogl.GL_EXTENSIONS).split(" ")
                if extensions[-1] == "":
                    extensions = extensions[:-1]
                results["testsuite_visual_opengl_extensions"] = extensions
            else:
                results["testsuite_visual_opengl_vendor"] = ""
                results["testsuite_visual_opengl_renderer"] = ""
                results["testsuite_visual_opengl_version"] = ""
                results["testsuite_visual_pygame_driver"] = ""
                results["testsuite_visual_opengl_extensions"] = ""
            results["testsuite_visual_pygame_driver"] = pygame.display.get_driver()
            results["testsuite_visual_pygame_screensize"] = exp.screen.size
            preselected_item = select + 1
        elif select == 1:
            results["testsuite_audio_user"] = _audio_playback(exp)
            try:
                results["testsuite_audio_frequency"] = str(pygame.mixer.get_init()[0]) + " Hz"
                results["testsuite_audio_bitdepth"] = str(abs(pygame.mixer.get_init()[1])) + " bit"
                results["testsuite_audio_channels"] = pygame.mixer.get_init()[2]
            except:
                presults["testsuite_audio_frequency"] = ""
                results["testsuite_audio_bitdepth"] = ""
                results["testsuite_audio_channels"] = ""
            preselected_item = select + 1
        else:
            exec(test_functions[select])
            results.update(rtn)
            preselected_item = select + 1

    if quit_experiment:
        expyriment.control.end(goodbye_delay=0, goodbye_text="Quitting test suite")
コード例 #4
0
ファイル: cli.py プロジェクト: pombredanne/expyriment
     print "* OpenGL (vsync / blocking)"
     expyriment.control.defaults.open_gl = 2
 elif arg == '3':
     print "* OpenGL (vsync / alternative blocking)"
     expyriment.control.defaults.open_gl = 3
 elif arg == 't':
     print "* No time stamps"
     expyriment.io.defaults.outputfile_time_stamp =\
             False
 elif arg == 'a':
     print "* Auto create subject id"
     expyriment.control.defaults.auto_create_subject_id\
                      = True
 elif arg == "S":
     print "System Info"
     print expyriment.get_system_info(as_string=True)
     sys.exit()
 elif arg == "T":
     print "Run Test Suite"
     expyriment.control.run_test_suite()
     sys.exit()
 elif arg == "B":
     expyriment.show_documentation(2)
     sys.exit()
 elif arg == "A":
     print "Start API Reference Tool"
     expyriment.show_documentation(3)
     sys.exit()
 elif arg == "C":
     create_template()
     sys.exit()