mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
* Added microsoft channel and playwright as dependency * Added test-setup to run * Basic tests for each example in examples/index.html * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update test_webgl_raycaster_index.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update test_folium.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update test_folium.py * Update test_folium.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update test_bokeh.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Whitelisting assertion statements in test files * Updated bare execept statements with ImportError * Flake8 compliance * Updated message * Removed 'make test-setup' * Removed @echo from make test * Uncommented Toga test * Removed __test_all__.py file * Removing unnecessary files * Removed individual test files * conftest.py with all data for running tests * Consolidated test file * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fixed pre-commit flake8 issues * flake8 issue * add playwright installation to setup * Testing parameterization and webserver to serve examples locally * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Flake8 compliance * More flake8 Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Michael Verhulst <michael@terminallabs.com> Co-authored-by: Fabio Pliger <fabio.pliger@gmail.com>
45 lines
1.0 KiB
Python
45 lines
1.0 KiB
Python
"""All data required for testing examples"""
|
|
import os
|
|
import threading
|
|
from http.server import HTTPServer as SuperHTTPServer
|
|
from http.server import SimpleHTTPRequestHandler
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
my_path = Path.cwd() / "examples"
|
|
os.chdir(my_path)
|
|
|
|
|
|
class HTTPServer(SuperHTTPServer):
|
|
"""
|
|
Class for wrapper to run SimpleHTTPServer on Thread.
|
|
Ctrl +Only Thread remains dead when terminated with C.
|
|
Keyboard Interrupt passes.
|
|
"""
|
|
|
|
def run(self):
|
|
try:
|
|
self.serve_forever()
|
|
except KeyboardInterrupt:
|
|
pass
|
|
finally:
|
|
self.server_close()
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def http_server():
|
|
host, port = "127.0.0.1", 8080
|
|
base_url = f"http://{host}:{port}"
|
|
|
|
# serve_Run forever under thread
|
|
server = HTTPServer((host, port), SimpleHTTPRequestHandler)
|
|
thread = threading.Thread(None, server.run)
|
|
thread.start()
|
|
|
|
yield base_url # Transition to test here
|
|
|
|
# End thread
|
|
server.shutdown()
|
|
thread.join()
|