Files
pyscript/pyscriptjs/tests/py-unit/conftest.py
Fabio Pliger d55340a817 Better test support for Python Plugins (#1108)
* add plugins testing utils module

* add plugins manager fixture and init plugins tests helper in conftest

* add _custom_elements attribute to pyscript.Plugin to allow plugins to track the CE they register

* add test for py_tutor

* remove unrelated code from prims js script

* ensure a Plugin always has the app attribute and improve tests

* add tests for py_tutor create_code_section

* implement PluginsManager reset and add teardown on plugins_manager fixture to clean it up after a test

* add test to check if plugin has been registered

* add docstrings to new tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add docstrings to plugins tester

* add changes from main

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* lint

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add todo to add remaining PluginsManager lifecycle events

Co-authored-by: Fabio Pliger <fpliger@anaconda.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-01-24 13:32:16 -08:00

29 lines
806 B
Python

"""All data required for testing examples"""
import pathlib
import sys
import pytest
# current working directory
base_path = pathlib.Path().absolute()
# add pyscript folder to path
python_source = base_path / "src" / "python"
sys.path.append(str(python_source))
# add Python plugins folder to path
python_plugins_source = base_path / "src" / "plugins" / "python"
sys.path.append(str(python_plugins_source))
# patch pyscript module where needed
import pyscript # noqa: E402
import pyscript_plugins_tester as ppt # noqa: E402
pyscript.define_custom_element = ppt.define_custom_element
@pytest.fixture()
def plugins_manager():
"""return a new instance of a Test version the PyScript application plugins manager"""
yield ppt.plugins_manager # PluginsManager()
ppt.plugins_manager.reset()