mirror of https://github.com/pyodide/pyodide.git
Copy test data in a pytest fixture
This commit is contained in:
parent
5c3b2eaae9
commit
153c6324b9
|
@ -63,7 +63,6 @@ jobs:
|
||||||
ccache -z
|
ccache -z
|
||||||
make
|
make
|
||||||
ccache -s
|
ccache -s
|
||||||
make build/test.html build/test_data.txt
|
|
||||||
|
|
||||||
- save_cache:
|
- save_cache:
|
||||||
paths:
|
paths:
|
||||||
|
@ -93,7 +92,7 @@ jobs:
|
||||||
|
|
||||||
source pyodide-env/bin/activate
|
source pyodide-env/bin/activate
|
||||||
export PATH=$PWD/firefox:$PATH
|
export PATH=$PWD/firefox:$PATH
|
||||||
pytest test -v --instafail -k firefox
|
pytest test -v -k firefox
|
||||||
|
|
||||||
test-chrome:
|
test-chrome:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
|
@ -110,7 +109,7 @@ jobs:
|
||||||
|
|
||||||
source pyodide-env/bin/activate
|
source pyodide-env/bin/activate
|
||||||
export PATH=$PWD/firefox:$PATH
|
export PATH=$PWD/firefox:$PATH
|
||||||
pytest test -v --instafail -k chrome
|
pytest test -v -k chrome
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
machine:
|
machine:
|
||||||
|
|
8
Makefile
8
Makefile
|
@ -101,12 +101,8 @@ build/renderedhtml.css: src/renderedhtml.less
|
||||||
lessc $< $@
|
lessc $< $@
|
||||||
|
|
||||||
|
|
||||||
test: all build/test.html build/test_data.txt
|
test: all
|
||||||
py.test test -v -r sxX --instafail
|
pytest test/ -v
|
||||||
|
|
||||||
|
|
||||||
build/test_data.txt: test/data.txt
|
|
||||||
cp test/data.txt build/test_data.txt
|
|
||||||
|
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
|
|
|
@ -43,7 +43,7 @@ Install [geckodriver](https://github.com/mozilla/geckodriver/releases) and
|
||||||
[chromedriver](https://sites.google.com/a/chromium.org/chromedriver/downloads) somewhere
|
[chromedriver](https://sites.google.com/a/chromium.org/chromedriver/downloads) somewhere
|
||||||
on your `PATH`.
|
on your `PATH`.
|
||||||
|
|
||||||
`make test`
|
`pytest test/`
|
||||||
|
|
||||||
# Benchmarking
|
# Benchmarking
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import multiprocessing
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import queue
|
import queue
|
||||||
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -39,6 +40,10 @@ class SeleniumWrapper:
|
||||||
|
|
||||||
driver = self.get_driver()
|
driver = self.get_driver()
|
||||||
wait = WebDriverWait(driver, timeout=20)
|
wait = WebDriverWait(driver, timeout=20)
|
||||||
|
if not (BUILD_PATH / 'test.html').exists():
|
||||||
|
# selenium does not expose HTTP response codes
|
||||||
|
raise ValueError(f"{(BUILD_PATH / 'test.html').resolve()} "
|
||||||
|
f"does not exist!")
|
||||||
driver.get(f'http://127.0.0.1:{PORT}/test.html')
|
driver.get(f'http://127.0.0.1:{PORT}/test.html')
|
||||||
wait.until(PyodideInited())
|
wait.until(PyodideInited())
|
||||||
self.wait = wait
|
self.wait = wait
|
||||||
|
@ -109,8 +114,16 @@ class ChromeWrapper(SeleniumWrapper):
|
||||||
|
|
||||||
|
|
||||||
if pytest is not None:
|
if pytest is not None:
|
||||||
|
|
||||||
|
@pytest.fixture(scope='session')
|
||||||
|
def setup_resources():
|
||||||
|
shutil.copyfile(TEST_PATH / 'data.txt',
|
||||||
|
BUILD_PATH / 'test_data.txt')
|
||||||
|
shutil.copyfile(TEST_PATH.parent / 'src' / 'test.html',
|
||||||
|
BUILD_PATH / 'test.html')
|
||||||
|
|
||||||
@pytest.fixture(params=['firefox', 'chrome'])
|
@pytest.fixture(params=['firefox', 'chrome'])
|
||||||
def selenium_standalone(request):
|
def selenium_standalone(request, setup_resources):
|
||||||
if request.param == 'firefox':
|
if request.param == 'firefox':
|
||||||
cls = FirefoxWrapper
|
cls = FirefoxWrapper
|
||||||
elif request.param == 'chrome':
|
elif request.param == 'chrome':
|
||||||
|
@ -123,7 +136,7 @@ if pytest is not None:
|
||||||
selenium.driver.quit()
|
selenium.driver.quit()
|
||||||
|
|
||||||
@pytest.fixture(params=['firefox', 'chrome'], scope='module')
|
@pytest.fixture(params=['firefox', 'chrome'], scope='module')
|
||||||
def _selenium_cached(request):
|
def _selenium_cached(request, setup_resources):
|
||||||
# Cached selenium instance. This is a copy-paste of
|
# Cached selenium instance. This is a copy-paste of
|
||||||
# selenium_standalone to avoid fixture scope issues
|
# selenium_standalone to avoid fixture scope issues
|
||||||
if request.param == 'firefox':
|
if request.param == 'firefox':
|
||||||
|
|
Loading…
Reference in New Issue