Commit 5030eae5 authored by Roman Yurchak's avatar Roman Yurchak

Re-use built-in web server

parent ff45a550
......@@ -205,5 +205,10 @@ def run_web_server(q):
httpd.serve_forever()
@pytest.fixture
def web_server():
return '127.0.0.1', PORT
if multiprocessing.current_process().name == 'MainProcess':
spawn_web_server()
import os
from pathlib import Path
from http.server import HTTPServer, SimpleHTTPRequestHandler
import threading
import pytest
def test_load_from_url(selenium_standalone, web_server):
@pytest.fixture
def static_web_server():
# serve artefacts from a different port
build_dir = Path(__file__).parent.parent / 'build'
os.chdir(build_dir)
try:
url, port = ('127.0.0.1', 8888)
server = HTTPServer((url, port), SimpleHTTPRequestHandler)
thread = threading.Thread(target=server.serve_forever)
thread.start()
yield url, port
finally:
server.shutdown()
def test_load_from_url(selenium_standalone, static_web_server):
url, port = static_web_server
url, port = web_server
selenium_standalone.load_package(f"http://{url}:{port}/pyparsing.js")
assert "Invalid package name or URI" not in selenium_standalone.logs
......@@ -32,6 +10,9 @@ def test_load_from_url(selenium_standalone, static_web_server):
selenium_standalone.run("from pyparsing import Word, alphas")
selenium_standalone.run("Word(alphas).parseString('hello')")
selenium_standalone.load_package(f"http://{url}:{port}/numpy.js")
selenium_standalone.run("import numpy as np")
def test_uri_mismatch(selenium_standalone):
selenium_standalone.load_package('pyparsing')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment