Commit af569129 authored by Michael Droettboom's avatar Michael Droettboom Committed by GitHub

Merge pull request #146 from rth/multi-line-code-snippets

MAINT Use multi-line code snippets in tests
parents 8c27b0b4 d869ac5b
......@@ -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} }}
......
This diff is collapsed.
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment