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_applications.application_path('designer'))], check=True, env=environment, timeout=20, ) assert (file_path.read_bytes() == pyqt5_plugins.tests.testbutton.test_file_contents)
def run(application_name, environment=os.environ): modified_environment = qt5_applications.create_environment(reference=environment) application_path = qt5_applications.application_path(application_name) completed_process = subprocess.run( [ fspath(application_path), *sys.argv[1:], ], env=modified_environment, ) sys.exit(completed_process.returncode)
def pyqtqmltestrunner( 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.utilities.create_env(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_applications.application_path('qmltestrunner')), *extras, *ctx.args, ] return subprocess.call(command, env=env)
def pyqtdesigner(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.utilities.create_env(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_applications.application_path('designer')), *extras, *ctx.args, ] return subprocess.call(command, env=env)
def pyqt5qmlscene( ctx, qml2_import_paths, qmlscene_help, qt_debug_plugins, run_qml_example, ): env = pyqt5_plugins.utilities.create_env(os.environ) extras = [] if qmlscene_help: extras.append('--help') if run_qml_example: qml2_import_paths = qml2_import_paths + ( pyqt5_plugins.utilities.fspath(here), ) extras.append( pyqt5_plugins.utilities.fspath( pathlib.Path(pyqt5_plugins.examples.__file__).parent / 'qmlapp.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_applications.application_path('qmlscene')), *extras, *ctx.args, ] return subprocess.call(command, env=env)
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_applications.application_path('qmltestrunner')), '-input', qml_test_path, ], check=True, env=environment, timeout=20, ) assert (file_path.read_bytes() == pyqt5_plugins.examples.exampleqmlitem.test_file_contents)
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_applications.application_path('qmlscene')), fspath(qml_example_path), ], check=True, env=environment, timeout=20, ) assert (file_path.read_bytes() == pyqt5_plugins.examples.exampleqmlitem.test_file_contents)