Commit aa433aaf authored by Michael Droettboom's avatar Michael Droettboom

Add first version of pyodide.py

parent d385b7c9
......@@ -144,6 +144,7 @@ root/.built: \
src/lazy_import.py \
src/sitecustomize.py \
src/webbrowser.py \
src/pyodide.py \
remove_modules.txt
rm -rf root
mkdir -p root/lib
......@@ -154,6 +155,7 @@ root/.built: \
cp src/webbrowser.py root/lib/python$(PYMINOR)
cp src/_testcapi.py root/lib/python$(PYMINOR)
cp src/pystone.py root/lib/python$(PYMINOR)
cp src/pyodide.py root/lib/python$(PYMINOR)/site-packages
( \
cd root/lib/python$(PYMINOR); \
rm -fr `cat ../../../remove_modules.txt`; \
......
# A library of helper utilities for connecting Python to the browser environment
from js import XMLHttpRequest
import io
def open_url(url):
"""
Fetches a given *url* and returns a io.StringIO to access its contents.
"""
req = XMLHttpRequest.new()
req.open('GET', url, False)
req.send(None)
return io.StringIO(req.response)
__all__ = ['open_url']
......@@ -48,6 +48,13 @@ def test_py_proxy(selenium):
assert selenium.run("hasattr(f, 'baz')") == False
def test_open_url(selenium):
assert selenium.run(
"import pyodide\n"
"pyodide.open_url('../test/data.txt').read()\n") == 'HELLO\n'
def test_run_core_python_test(python_test, selenium):
selenium.run(
"import sys\n"
......
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