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
2ad135ef
Commit
2ad135ef
authored
Mar 30, 2018
by
Michael Droettboom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add testing
parent
eab618ec
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
104 additions
and
10 deletions
+104
-10
.gitignore
.gitignore
+12
-10
Makefile
Makefile
+4
-0
README.md
README.md
+11
-0
test/__init__.py
test/__init__.py
+0
-0
test/conftest.py
test/conftest.py
+52
-0
test/test_numpy.py
test/test_numpy.py
+7
-0
test/test_python.py
test/test_python.py
+18
-0
No files found.
.gitignore
View file @
2ad135ef
root/
build/pyodide.js
build/pyodide.asm.*
*.bc
*.a
.pytest_cache/
__pycache__
cpython/build
cpython/downloads
cpython/installs
/root/
/build/
numpy/build
numpy/host
numpy/downloads
numpy/.patched
\ No newline at end of file
/cpython/build
/cpython/downloads
/cpython/installs
/numpy/build
/numpy/host
/numpy/downloads
/numpy/.patched
\ No newline at end of file
Makefile
View file @
2ad135ef
...
...
@@ -44,6 +44,10 @@ build/pyodide.js: src/pyodide.js
cp
$<
$@
test
:
all
py.test
test
clean
:
rm
-fr
root
rm
build/
*
...
...
README.md
View file @
2ad135ef
...
...
@@ -16,3 +16,14 @@ These instructions were tested on Linux. OSX should be substantively the same.
3.
Build this project.
Type
`make`
.
# Testing
1.
Install the following dependencies into the default Python installation:
`pip install pytest selenium`
2.
Install
[
geckodriver
](
https://github.com/mozilla/geckodriver/releases
)
somewhere
on your
`PATH`
.
3.
`make test`
test/__init__.py
0 → 100644
View file @
2ad135ef
test/conftest.py
0 → 100644
View file @
2ad135ef
"""
Various common utilities for testing.
"""
import
pathlib
import
pytest
TEST_PATH
=
pathlib
.
Path
(
__file__
).
parents
[
0
].
resolve
()
BUILD_PATH
=
TEST_PATH
/
'..'
/
'build'
class
PyodideInited
:
def
__call__
(
self
,
driver
):
inited
=
driver
.
execute_script
(
"return pyodide.runPython"
)
return
inited
is
not
None
class
SeleniumWrapper
:
def
__init__
(
self
):
from
selenium.webdriver
import
Firefox
from
selenium.webdriver.firefox.options
import
Options
from
selenium.webdriver.support.wait
import
WebDriverWait
options
=
Options
()
options
.
add_argument
(
'-headless'
)
driver
=
Firefox
(
executable_path
=
'geckodriver'
,
firefox_options
=
options
)
wait
=
WebDriverWait
(
driver
,
timeout
=
20
)
driver
.
get
((
BUILD_PATH
/
"test.html"
).
as_uri
())
wait
.
until
(
PyodideInited
())
self
.
driver
=
driver
@
property
def
logs
(
self
):
return
self
.
driver
.
execute_script
(
"return window.logs"
)
def
run
(
self
,
code
):
return
self
.
driver
.
execute_script
(
'return pyodide.runPython({!r})'
.
format
(
code
))
@
property
def
urls
(
self
):
for
handle
in
self
.
driver
.
window_handles
:
self
.
driver
.
switch_to
.
window
(
handle
)
yield
self
.
driver
.
current_url
@
pytest
.
fixture
def
selenium
():
return
SeleniumWrapper
()
test/test_numpy.py
0 → 100644
View file @
2ad135ef
def
test_numpy
(
selenium
):
selenium
.
run
(
"import numpy"
)
x
=
selenium
.
run
(
"numpy.zeros((32, 64))"
)
assert
len
(
x
)
==
32
assert
all
(
len
(
y
)
==
64
for
y
in
x
)
for
y
in
x
:
assert
all
(
z
==
0
for
z
in
y
)
test/test_python.py
0 → 100644
View file @
2ad135ef
import
time
def
test_init
(
selenium
):
assert
'Python initialization complete'
in
selenium
.
logs
assert
len
(
selenium
.
driver
.
window_handles
)
==
1
def
test_webbrowser
(
selenium
):
selenium
.
run
(
"import antigravity"
)
time
.
sleep
(
2
)
assert
len
(
selenium
.
driver
.
window_handles
)
==
2
assert
any
(
'xkcd.com'
in
x
for
x
in
selenium
.
urls
)
def
test_print
(
selenium
):
selenium
.
run
(
"print('This should be logged')"
)
assert
'This should be logged'
in
selenium
.
logs
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