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
af569129
Commit
af569129
authored
Sep 07, 2018
by
Michael Droettboom
Committed by
GitHub
Sep 07, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #146 from rth/multi-line-code-snippets
MAINT Use multi-line code snippets in tests
parents
8c27b0b4
d869ac5b
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
184 additions
and
134 deletions
+184
-134
test/conftest.py
test/conftest.py
+7
-0
test/test_python.py
test/test_python.py
+163
-125
test/test_testing.py
test/test_testing.py
+14
-9
No files found.
test/conftest.py
View file @
af569129
...
...
@@ -4,6 +4,7 @@ Various common utilities for testing.
import
atexit
import
multiprocessing
import
textwrap
import
os
import
pathlib
import
queue
...
...
@@ -73,10 +74,16 @@ class SeleniumWrapper:
self
.
driver
.
execute_script
(
"window.logs = []"
)
def
run
(
self
,
code
):
if
isinstance
(
code
,
str
)
and
code
.
startswith
(
'
\
n
'
):
# we have a multiline string, fix indentation
code
=
textwrap
.
dedent
(
code
)
return
self
.
run_js
(
'return pyodide.runPython({!r})'
.
format
(
code
))
def
run_js
(
self
,
code
):
if
isinstance
(
code
,
str
)
and
code
.
startswith
(
'
\
n
'
):
# we have a multiline string, fix indentation
code
=
textwrap
.
dedent
(
code
)
catch
=
f"""
Error.stackTraceLimit = Infinity;
try {{
{
code
}
}}
...
...
test/test_python.py
View file @
af569129
This diff is collapsed.
Click to expand it.
test/test_testing.py
View file @
af569129
def
test_pytest
(
selenium
):
selenium
.
load_package
(
'pytest'
)
selenium
.
load_package
(
'numpy'
)
selenium
.
load_package
(
'nose'
)
selenium
.
run
(
'from pathlib import Path'
)
selenium
.
run
(
'import os'
)
selenium
.
run
(
'import numpy'
)
selenium
.
run
(
'base_dir = Path(numpy.__file__).parent / "core" / "tests"'
)
selenium
.
run
(
"import pytest;"
"pytest.main([base_dir / 'test_api.py'])"
)
selenium
.
load_package
([
'pytest'
,
'numpy'
,
'nose'
])
selenium
.
run
(
"""
from pathlib import Path
import os
import numpy
import pytest
base_dir = Path(numpy.__file__).parent / "core" / "tests"
"""
)
selenium
.
run
(
"pytest.main([base_dir / 'test_api.py'])"
)
logs
=
'
\
n
'
.
join
(
selenium
.
logs
)
assert
'INTERNALERROR'
not
in
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