Beispiel #1
0
def test_designer_creates_test_widget(tmp_path, environment):
    file_path = tmp_path / 'tigger'
    environment[pyqt5_plugins.tests.testbutton.test_path_env_var] = fspath(
        file_path)

    widget_plugin_path = pathlib.Path(
        pyqt5_plugins.tests.testbuttonplugin.__file__, ).parent

    environment.update(
        pyqt5_plugins.utilities.add_to_env_var_path_list(
            env=environment,
            name='PYQTDESIGNERPATH',
            before=[fspath(widget_plugin_path)],
            after=[''],
        ))

    pyqt5_plugins.utilities.print_environment_variables(
        environment, *vars_to_print)

    with pytest.raises(subprocess.TimeoutExpired):
        subprocess.run(
            [fspath(qt5_tools.application_path('designer'))],
            check=True,
            env=environment,
            timeout=40,
        )

    assert (file_path.read_bytes() ==
            pyqt5_plugins.tests.testbutton.test_file_contents)
Beispiel #2
0
def test_designer_creates_test_widget(tmp_path, environment):
    file_path = tmp_path / 'tigger'
    environment[pyqt5_plugins.tests.testbutton.test_path_env_var] = fspath(
        file_path)

    widget_plugin_path = pathlib.Path(
        pyqt5_plugins.tests.testbuttonplugin.__file__, ).parent

    environment.update(
        pyqt5_plugins.utilities.add_to_env_var_path_list(
            env=environment,
            name='PYQTDESIGNERPATH',
            before=[fspath(widget_plugin_path)],
            after=[''],
        ))

    pyqt5_plugins.utilities.print_environment_variables(
        environment, *vars_to_print)

    contents = run_for_file(
        [fspath(qt5_tools.application_path('designer'))],
        env=environment,
        file_path=file_path,
    )

    assert contents == pyqt5_plugins.tests.testbutton.test_file_contents
def qmltestrunner(
    ctx,
    qml2_import_paths,
    qmltestrunner_help,
    qt_debug_plugins,
    test_qml_example,
):
    # here for now at least since it still mutates
    load_dotenv()
    env = pyqt5_plugins.create_environment(os.environ)
    extras = []

    if qmltestrunner_help:
        extras.append('--help')

    if test_qml_example:
        qml2_import_paths = qml2_import_paths + (
            pyqt5_plugins.utilities.fspath(here), )
        extras.extend([
            '-input',
            pyqt5_plugins.utilities.fspath(
                pathlib.Path(pyqt5_plugins.examples.__file__).parent /
                'qmltest.qml'),
        ])

    pyqt5_plugins.utilities.mutate_qml_path(env, paths=qml2_import_paths)

    if qt_debug_plugins:
        env['QT_DEBUG_PLUGINS'] = '1'

    pyqt5_plugins.utilities.print_environment_variables(
        env,
        *pyqt5_plugins.utilities.diagnostic_variables_to_print,
    )

    command = [
        pyqt5_plugins.utilities.fspath(
            qt5_tools.application_path('qmltestrunner')),
        *extras,
        *ctx.args,
    ]

    return subprocess.call(command, env=env)
def designer(ctx, widget_paths, designer_help, example_widget_path,
             test_exception_dialog, qt_debug_plugins):
    # here for now at least since it still mutates
    load_dotenv()
    env = pyqt5_plugins.create_environment(reference=os.environ)

    extras = []
    widget_paths = list(widget_paths)

    if designer_help:
        extras.append('--help')

    if example_widget_path:
        widget_paths.append(example_path)

    if test_exception_dialog:
        widget_paths.append(bad_path)

    env.update(
        pyqt5_plugins.utilities.add_to_env_var_path_list(
            env=env,
            name='PYQTDESIGNERPATH',
            before=widget_paths,
            after=[''],
        ))

    if qt_debug_plugins:
        env['QT_DEBUG_PLUGINS'] = '1'

    pyqt5_plugins.utilities.print_environment_variables(
        env,
        *pyqt5_plugins.utilities.diagnostic_variables_to_print,
    )

    command = [
        pyqt5_plugins.utilities.fspath(qt5_tools.application_path('designer')),
        *extras,
        *ctx.args,
    ]

    return subprocess.call(command, env=env)
Beispiel #5
0
def test_qmlscene_paints_test_item(tmp_path, environment):
    file_path = tmp_path / 'eeyore'
    environment[pyqt5_plugins.examples.exampleqmlitem.
                test_path_env_var] = fspath(file_path)

    qml_example_path = pyqt5_plugins.utilities.fspath(
        pathlib.Path(pyqt5_plugins.examples.__file__).parent / 'qmlapp.qml')

    pyqt5_plugins.utilities.print_environment_variables(
        environment, *vars_to_print)

    contents = run_for_file(
        [
            fspath(qt5_tools.application_path('qmlscene')),
            fspath(qml_example_path),
        ],
        env=environment,
        file_path=file_path,
    )

    assert contents == pyqt5_plugins.examples.exampleqmlitem.test_file_contents
Beispiel #6
0
def test_qmltestrunner_paints_test_item(tmp_path, environment):
    file_path = tmp_path / 'piglet'
    environment[pyqt5_plugins.examples.exampleqmlitem.
                test_path_env_var] = fspath(file_path)

    qml_test_path = pyqt5_plugins.utilities.fspath(
        pathlib.Path(pyqt5_plugins.examples.__file__).parent / 'qmltest.qml')

    pyqt5_plugins.utilities.print_environment_variables(
        environment, *vars_to_print)

    subprocess.run(
        [
            fspath(qt5_tools.application_path('qmltestrunner')),
            '-input',
            qml_test_path,
        ],
        check=True,
        env=environment,
        timeout=40,
    )

    assert (file_path.read_bytes() ==
            pyqt5_plugins.examples.exampleqmlitem.test_file_contents)
Beispiel #7
0
def test_qmlscene_paints_test_item(tmp_path, environment):
    file_path = tmp_path / 'eeyore'
    environment[pyqt5_plugins.examples.exampleqmlitem.
                test_path_env_var] = fspath(file_path)

    qml_example_path = pyqt5_plugins.utilities.fspath(
        pathlib.Path(pyqt5_plugins.examples.__file__).parent / 'qmlapp.qml')

    pyqt5_plugins.utilities.print_environment_variables(
        environment, *vars_to_print)

    with pytest.raises(subprocess.TimeoutExpired):
        subprocess.run(
            [
                fspath(qt5_tools.application_path('qmlscene')),
                fspath(qml_example_path),
            ],
            check=True,
            env=environment,
            timeout=40,
        )

    assert (file_path.read_bytes() ==
            pyqt5_plugins.examples.exampleqmlitem.test_file_contents)