mirror of https://github.com/pyodide/pyodide.git
Fix matplotlib tests
This commit is contained in:
parent
9245f6f246
commit
ce15a29157
|
@ -118,8 +118,8 @@ if pytest is not None:
|
|||
|
||||
@pytest.fixture(params=['firefox', 'chrome'], scope='module')
|
||||
def _selenium_cached(request):
|
||||
# intermediary cached selenium instance, this is a copy
|
||||
# of the selenium_standalone to avoid fixture scope issues
|
||||
# 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':
|
||||
|
@ -132,9 +132,9 @@ if pytest is not None:
|
|||
|
||||
@pytest.fixture
|
||||
def selenium(_selenium_cached):
|
||||
# this is selenium instance cached at the module level
|
||||
# selenium instance cached at the module level
|
||||
try:
|
||||
# for each test run, we clean selenium logs
|
||||
# clean selenium logs for each test run
|
||||
_selenium_cached.driver.execute_script("window.logs = []")
|
||||
yield _selenium_cached
|
||||
finally:
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
def test_matplotlib(selenium):
|
||||
selenium.load_package("matplotlib")
|
||||
selenium.run("from matplotlib import pyplot as plt")
|
||||
selenium.run("plt.figure()")
|
||||
selenium.run("x = plt.plot([1,2,3])")
|
||||
selenium.run("plt.destroy_all()")
|
||||
|
||||
|
||||
def test_svg(selenium):
|
||||
selenium.load_package("matplotlib")
|
||||
selenium.run("from matplotlib import pyplot as plt")
|
||||
selenium.run("plt.figure()")
|
||||
selenium.run("x = plt.plot([1,2,3])")
|
||||
selenium.run("import io")
|
||||
selenium.run("fd = io.BytesIO()")
|
||||
|
@ -14,3 +17,4 @@ def test_svg(selenium):
|
|||
content = selenium.run("fd.getvalue().decode('utf8')")
|
||||
assert len(content) == 15752
|
||||
assert content.startswith("<?xml")
|
||||
selenium.run("plt.destroy_all()")
|
||||
|
|
Loading…
Reference in New Issue