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
075ffca0
Commit
075ffca0
authored
Jul 09, 2018
by
Michael Droettboom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle catching Javascript exceptions in a unified way
parent
aa034381
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
test/conftest.py
test/conftest.py
+8
-0
test/test_python.py
test/test_python.py
+3
-5
No files found.
test/conftest.py
View file @
075ffca0
...
...
@@ -73,9 +73,13 @@ class FirefoxWrapper(SeleniumWrapper):
def
get_driver
(
self
):
from
selenium.webdriver
import
Firefox
from
selenium.webdriver.firefox.options
import
Options
from
selenium.common.exceptions
import
JavascriptException
options
=
Options
()
options
.
add_argument
(
'-headless'
)
self
.
JavascriptException
=
JavascriptException
return
Firefox
(
executable_path
=
'geckodriver'
,
firefox_options
=
options
)
...
...
@@ -84,9 +88,13 @@ class ChromeWrapper(SeleniumWrapper):
def
get_driver
(
self
):
from
selenium.webdriver
import
Chrome
from
selenium.webdriver.chrome.options
import
Options
from
selenium.common.exceptions
import
WebDriverException
options
=
Options
()
options
.
add_argument
(
'--headless'
)
self
.
JavascriptException
=
WebDriverException
return
Chrome
(
chrome_options
=
options
)
...
...
test/test_python.py
View file @
075ffca0
...
...
@@ -2,8 +2,6 @@ import os
import
pathlib
import
time
from
selenium.common.exceptions
import
JavascriptException
def
test_init
(
selenium
):
assert
'Python initialization complete'
in
selenium
.
logs
...
...
@@ -50,7 +48,7 @@ def test_python2js(selenium):
def
test_pythonexc2js
(
selenium
):
try
:
selenium
.
run_js
(
'return pyodide.runPython("5 / 0")'
)
except
JavascriptException
as
e
:
except
selenium
.
JavascriptException
as
e
:
assert
(
'ZeroDivisionError'
in
str
(
e
))
else
:
assert
False
,
'Expected exception'
...
...
@@ -147,7 +145,7 @@ def test_pyproxy_destroy(selenium):
"console.assert(f.get_value(1) === 64);
\
n
"
"f.destroy();
\
n
"
"f.get_value();
\
n
"
)
except
JavascriptException
as
e
:
except
selenium
.
JavascriptException
as
e
:
assert
'Object has already been destroyed'
in
str
(
e
)
else
:
assert
False
,
'Expected exception'
...
...
@@ -186,7 +184,7 @@ def test_run_core_python_test(python_test, selenium):
selenium
.
run
(
"from test.libregrtest import main
\
n
"
"main(['{}'], verbose=True, verbose3=True)"
.
format
(
python_test
))
except
JavascriptException
as
e
:
except
selenium
.
JavascriptException
as
e
:
assert
str
(
e
).
strip
().
endswith
(
'SystemExit: 0'
)
...
...
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