Exemplo n.º 1
0
def test_actions_gui(qtbot, gui, actions):
    qtbot.addWidget(gui)
    gui.show()
    qtbot.waitForWindowShown(gui)

    _press = []

    @actions.add(shortcut='g')
    def press():
        _press.append(0)

    actions.press()
    assert _press == [0]

    # Show action shortcuts.
    with captured_output() as (stdout, stderr):
        actions.show_shortcuts()
    assert 'g\n' in stdout.getvalue()

    # Show default action shortcuts.
    with captured_output() as (stdout, stderr):
        gui.file_actions.show_shortcuts()
    assert 'q\n' in stdout.getvalue()

    # Show all action shortcuts.
    with captured_output() as (stdout, stderr):
        gui.help_actions.show_all_shortcuts()
    assert 'g\n' in stdout.getvalue()
Exemplo n.º 2
0
def test_show_snippets():
    snippets = {
        'test_1 (note)': 't1',
    }
    with captured_output() as (stdout, stderr):
        _show_snippets(snippets, 'test')
    assert ':t1' in stdout.getvalue()
Exemplo n.º 3
0
def test_kwik_describe(qtbot, tempdir):
    temp_path = download_test_file('kwik/hybrid_10sec.kwik')
    kwik_path = tempdir / temp_path.name
    shutil.copy(temp_path, kwik_path)
    with captured_output() as (stdout, stderr):
        kwik_describe(str(kwik_path))
    assert stdout.getvalue()
Exemplo n.º 4
0
def _get_shortcuts(cls):
    with captured_output() as (stdout, stderr):
        print(cls.__name__)
        print('-' * len(cls.__name__))
        print()
        _show_shortcuts(cls.default_shortcuts)
        _show_snippets(cls.default_snippets)
    return stdout.getvalue()
Exemplo n.º 5
0
def test_model_1(template_model):
    with captured_output() as (stdout, stderr):
        template_model.describe()
    out = stdout.getvalue()
    print(out)
    assert 'sim_binary.dat' in out
    if '(300000, 32)' not in out:
        assert 'Data shape              None' in out
    assert '64' in out
Exemplo n.º 6
0
def test_show_shortcuts(qapp):
    # NOTE: a Qt application needs to be running so that we can use the
    # KeySequence.
    shortcuts = {
        'test_1': 'ctrl+t',
        'test_2': ('ctrl+a', 'shift+b'),
        'test_3': 'ctrl+z',
    }
    with captured_output() as (stdout, stderr):
        _show_shortcuts(shortcuts, 'test')
    assert 'ctrl+a, shift+b' in stdout.getvalue()
    assert 'ctrl+z' in stdout.getvalue()
Exemplo n.º 7
0
def test_actions_dialog_1(qtbot, gui, actions):
    @actions.add(shortcut='a', prompt=True)
    def hello(arg):
        print("hello", arg)

    qtbot.addWidget(gui)
    gui.show()
    qtbot.waitForWindowShown(gui)

    with captured_output() as (stdout, stderr):
        with mock_dialogs(('world', True)):
            # return string, ok
            actions.get('hello').trigger()
    assert 'hello world' in stdout.getvalue()
Exemplo n.º 8
0
def test_template_describe(qtbot, tempdir):
    model = load_model(
        _make_dataset(tempdir, param='dense', has_spike_attributes=False))
    with captured_output() as (stdout, stderr):
        template_describe(model.dir_path / 'params.py')
    assert '314' in stdout.getvalue()
Exemplo n.º 9
0
 def show_my_shortcuts():
     with captured_output() as (stdout, stderr):
         actions.show_shortcuts()
     _captured.append(stdout.getvalue())
Exemplo n.º 10
0
def _get_shortcuts(cls):
    with captured_output() as (stdout, stderr):
        _show_shortcuts(cls.default_shortcuts, cls.__name__)
        _show_snippets(cls.default_snippets, cls.__name__)
    return stdout.getvalue()
Exemplo n.º 11
0
def test_model_1(template_model_full):
    with captured_output() as (stdout, stderr):
        template_model_full.describe()
    out = stdout.getvalue()
    assert 'sim_binary.dat' in out
    assert '64' in out