Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyodide
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
pyodide
Commits
5030eae5
Commit
5030eae5
authored
Aug 23, 2018
by
Roman Yurchak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-use built-in web server
parent
ff45a550
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
24 deletions
+10
-24
test/conftest.py
test/conftest.py
+5
-0
test/test_package_loading.py
test/test_package_loading.py
+5
-24
No files found.
test/conftest.py
View file @
5030eae5
...
...
@@ -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
()
test/test_package_loading.py
View file @
5030eae5
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'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment