Files
pyscript/pyscriptjs/tests/py-unit/conftest.py
Hood Chatham 854e9d1378 Refactor pyexec (#1318)
This is some refactoring I did on the way towards resolving pyscript#1313.
I added a new _run_pyscript Python function which executes the code
inside a context manager that sets the display target. We can then
return a JS object wrapper directly from Python.

I moved the "installation" of the pyscript module to loadInterpreter,
and pyimport pyscript_py there and give it a type. This avoids a bunch
of creating and deleting of proxies for pyscript_py and allows us to
give it a type once and for all.

I also did some minor logic cleanup in a few places.
2023-03-30 04:34:24 +02:00

30 lines
793 B
Python

"""All data required for testing examples"""
import sys
from pathlib import Path
import pytest
pyscriptjs = Path(__file__).parents[2]
# add pyscript folder to path
python_source = pyscriptjs / "src" / "python"
sys.path.append(str(python_source))
# add Python plugins folder to path
python_plugins_source = pyscriptjs / "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()