diff --git a/test/conftest.py b/test/conftest.py index 1d1b93bf9..9d11f7307 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -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() diff --git a/test/test_package_loading.py b/test/test_package_loading.py index 590d27e90..52f0d8338 100644 --- a/test/test_package_loading.py +++ b/test/test_package_loading.py @@ -1,30 +1,8 @@ -import os -from pathlib import Path - -from http.server import HTTPServer, SimpleHTTPRequestHandler -import threading - -import pytest -@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, web_server): - -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')