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
9ad6830e
Commit
9ad6830e
authored
Aug 20, 2018
by
Michael Droettboom
Committed by
GitHub
Aug 20, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #118 from rth/reuse-selenium
Reuse selenium fixture in tests
parents
b47713d4
ee8ac747
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
12 deletions
+39
-12
test/conftest.py
test/conftest.py
+25
-1
test/python_tests.txt
test/python_tests.txt
+1
-1
test/test_common.py
test/test_common.py
+8
-7
test/test_matplotlib.py
test/test_matplotlib.py
+2
-0
test/test_python.py
test/test_python.py
+3
-3
No files found.
test/conftest.py
View file @
9ad6830e
...
@@ -104,7 +104,7 @@ class ChromeWrapper(SeleniumWrapper):
...
@@ -104,7 +104,7 @@ class ChromeWrapper(SeleniumWrapper):
if
pytest
is
not
None
:
if
pytest
is
not
None
:
@
pytest
.
fixture
(
params
=
[
'firefox'
,
'chrome'
])
@
pytest
.
fixture
(
params
=
[
'firefox'
,
'chrome'
])
def
selenium
(
request
):
def
selenium
_standalone
(
request
):
if
request
.
param
==
'firefox'
:
if
request
.
param
==
'firefox'
:
cls
=
FirefoxWrapper
cls
=
FirefoxWrapper
elif
request
.
param
==
'chrome'
:
elif
request
.
param
==
'chrome'
:
...
@@ -116,6 +116,30 @@ if pytest is not None:
...
@@ -116,6 +116,30 @@ if pytest is not None:
print
(
'
\
n
'
.
join
(
str
(
x
)
for
x
in
selenium
.
logs
))
print
(
'
\
n
'
.
join
(
str
(
x
)
for
x
in
selenium
.
logs
))
selenium
.
driver
.
quit
()
selenium
.
driver
.
quit
()
@
pytest
.
fixture
(
params
=
[
'firefox'
,
'chrome'
],
scope
=
'module'
)
def
_selenium_cached
(
request
):
# Cached selenium instance. This is a copy-paste of
# selenium_standalone to avoid fixture scope issues
if
request
.
param
==
'firefox'
:
cls
=
FirefoxWrapper
elif
request
.
param
==
'chrome'
:
cls
=
ChromeWrapper
selenium
=
cls
()
try
:
yield
selenium
finally
:
selenium
.
driver
.
quit
()
@
pytest
.
fixture
def
selenium
(
_selenium_cached
):
# selenium instance cached at the module level
try
:
# clean selenium logs for each test run
_selenium_cached
.
driver
.
execute_script
(
"window.logs = []"
)
yield
_selenium_cached
finally
:
print
(
'
\
n
'
.
join
(
str
(
x
)
for
x
in
_selenium_cached
.
logs
))
PORT
=
0
PORT
=
0
...
...
test/python_tests.txt
View file @
9ad6830e
...
@@ -368,7 +368,7 @@ test_repl subprocess
...
@@ -368,7 +368,7 @@ test_repl subprocess
test_reprlib
test_reprlib
test_resource
test_resource
test_richcmp
test_richcmp
test_rlcompleter
test_rlcompleter
crash
test_robotparser
test_robotparser
test_runpy crash
test_runpy crash
test_sax
test_sax
...
...
test/test_common.py
View file @
9ad6830e
...
@@ -32,16 +32,17 @@ UNSUPPORTED_PACKAGES = {'ChromeWrapper': ['pandas'],
...
@@ -32,16 +32,17 @@ UNSUPPORTED_PACKAGES = {'ChromeWrapper': ['pandas'],
@
pytest
.
mark
.
parametrize
(
'name'
,
registered_packages
())
@
pytest
.
mark
.
parametrize
(
'name'
,
registered_packages
())
def
test_import
(
name
,
selenium
):
def
test_import
(
name
,
selenium
_standalone
):
# check that we can parse the meta.yaml
# check that we can parse the meta.yaml
meta
=
common
.
parse_package
(
PKG_DIR
/
name
/
'meta.yaml'
)
meta
=
common
.
parse_package
(
PKG_DIR
/
name
/
'meta.yaml'
)
if
name
in
UNSUPPORTED_PACKAGES
[
selenium
.
__class__
.
__name__
]:
if
name
in
UNSUPPORTED_PACKAGES
[
selenium
_standalone
.
__class__
.
__name__
]:
pytest
.
xfail
(
pytest
.
xfail
(
'{} fails to load and is not supported on {}.'
'{} fails to load and is not supported on {}.'
.
format
(
name
,
.
format
(
name
,
selenium
.
__class__
.
__name__
.
replace
(
'Wrapper'
,
''
)))
selenium_standalone
.
__class__
.
__name__
.
replace
(
'Wrapper'
,
''
)))
for
import_name
in
meta
.
get
(
'test'
,
{}).
get
(
'imports'
,
[]):
for
import_name
in
meta
.
get
(
'test'
,
{}).
get
(
'imports'
,
[]):
selenium
.
load_package
(
name
)
selenium
_standalone
.
load_package
(
name
)
selenium
.
run
(
'import %s'
%
import_name
)
selenium
_standalone
.
run
(
'import %s'
%
import_name
)
test/test_matplotlib.py
View file @
9ad6830e
def
test_matplotlib
(
selenium
):
def
test_matplotlib
(
selenium
):
selenium
.
load_package
(
"matplotlib"
)
selenium
.
load_package
(
"matplotlib"
)
selenium
.
run
(
"from matplotlib import pyplot as plt"
)
selenium
.
run
(
"from matplotlib import pyplot as plt"
)
selenium
.
run
(
"plt.figure()"
)
selenium
.
run
(
"x = plt.plot([1,2,3])"
)
selenium
.
run
(
"x = plt.plot([1,2,3])"
)
def
test_svg
(
selenium
):
def
test_svg
(
selenium
):
selenium
.
load_package
(
"matplotlib"
)
selenium
.
load_package
(
"matplotlib"
)
selenium
.
run
(
"from matplotlib import pyplot as plt"
)
selenium
.
run
(
"from matplotlib import pyplot as plt"
)
selenium
.
run
(
"plt.figure()"
)
selenium
.
run
(
"x = plt.plot([1,2,3])"
)
selenium
.
run
(
"x = plt.plot([1,2,3])"
)
selenium
.
run
(
"import io"
)
selenium
.
run
(
"import io"
)
selenium
.
run
(
"fd = io.BytesIO()"
)
selenium
.
run
(
"fd = io.BytesIO()"
)
...
...
test/test_python.py
View file @
9ad6830e
...
@@ -6,9 +6,9 @@ import time
...
@@ -6,9 +6,9 @@ import time
import
pytest
import
pytest
def
test_init
(
selenium
):
def
test_init
(
selenium
_standalone
):
assert
'Python initialization complete'
in
selenium
.
logs
assert
'Python initialization complete'
in
selenium
_standalone
.
logs
assert
len
(
selenium
.
driver
.
window_handles
)
==
1
assert
len
(
selenium
_standalone
.
driver
.
window_handles
)
==
1
def
test_webbrowser
(
selenium
):
def
test_webbrowser
(
selenium
):
...
...
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