Introduce PyScriptTest, an helper class to write integration tests (#663)

This PR is about integration tests: they use playwright to load HTML pages in the browser and check that PyScript works as intended, as opposed to unit tests like the ones being introduced by #665 and #661.

The main goal of this PR is to introduce some machinery to make such tests easier to write, read and maintain, with some attention to capture enough information to produce useful error messages in case they fail in the CI.

In order to use the machinery, you need to subclass tests.support.PyScriptTest, which provides several useful API calls in the form self.xxx().

See the full description here:
https://github.com/pyscript/pyscript/pull/663

Co-authored-by: Mariana Meireles <marian.meireles@gmail.com>
Co-authored-by: mariana <marianameireles@protonmail.com>
This commit is contained in:
Antonio Cuni
2022-08-10 12:29:59 +02:00
committed by GitHub
parent bd7a20309b
commit 513dfe0b42
8 changed files with 684 additions and 2 deletions

View File

@@ -17,6 +17,8 @@ from urllib.parse import urljoin
import pytest
from .support import ROOT
MAX_TEST_TIME = 30 # Number of seconds allowed for checking a testing condition
TEST_TIME_INCREMENT = 0.25 # 1/4 second, the length of each iteration
TEST_ITERATIONS = math.ceil(
@@ -188,6 +190,9 @@ def wait_for_render(page, selector, pattern):
@pytest.mark.parametrize("example", EXAMPLES)
def test_examples(example, http_server, page):
# make sure that the http server serves from the right directory
ROOT.join("pyscriptjs").chdir()
base_url = http_server
example_path = urljoin(base_url, TEST_PARAMS[example]["file"])