Skip to content

Commit

Permalink
use session scope for utest performance, increase atest timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl committed Sep 20, 2023
1 parent bc59fda commit 6219137
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions tests/acceptance/Classic.robot
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ Launch Browser Tab
Click Launcher foo
Wait Until Keyword Succeeds 3x 0.5s Switch Window title:Hello World
Location Should Contain foo
Page Should Contain Hello World
Wait Until Page Contains Hello World timeout=10s
Close Window

Launch Another Browser Tab
Click Launcher bar
Wait Until Keyword Succeeds 3x 0.5s Switch Window title:Hello World
Location Should Contain bar
Page Should Contain Hello World
Wait Until Page Contains Hello World timeout=10s
Close Window
4 changes: 2 additions & 2 deletions tests/acceptance/Lab.robot
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ Launch Browser Tab
Click Launcher foo
Wait Until Keyword Succeeds 3x 0.5s Switch Window title:Hello World
Location Should Contain foo
Page Should Contain Hello World
Wait Until Page Contains Hello World timeout=10s
Close Window
[Teardown] Switch Window title:JupyterLab

Launch Lab Tab
Click Launcher bar
Wait Until Page Contains Element css:iframe
Select Frame css:iframe
Page Should Contain Hello World
Wait Until Page Contains Hello World timeout=10s

*** Keywords ***
Start Lab Tests
Expand Down
15 changes: 9 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
from urllib.request import urlopen
from uuid import uuid4

from pytest import fixture
from pytest import fixture, TempPathFactory

HERE = Path(__file__).parent
RESOURCES = HERE / "resources"


@fixture
@fixture(scope="session")
def a_token() -> str:
"""Get a random UUID to use for a token."""
return str(uuid4())


@fixture
@fixture(scope="session")
def an_unused_port() -> int:
"""Get a random unused port."""
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Expand All @@ -34,20 +34,23 @@ def an_unused_port() -> int:
return port


@fixture(params=["notebook", "lab"])
@fixture(params=["notebook", "lab"], scope="session")
def a_server_cmd(request: Any) -> str:
"""Get a viable name for a command."""
return request.param


@fixture
@fixture(scope="session")
def a_server(
a_server_cmd: str,
tmp_path: Path,
tmp_path_factory: TempPathFactory,
an_unused_port: int,
a_token: str,
) -> Generator[str, None, None]:
"""Get a running server."""

tmp_path = tmp_path_factory.mktemp(a_server_cmd)

# get a copy of the resources
tests = tmp_path / "tests"
tests.mkdir()
Expand Down

0 comments on commit 6219137

Please sign in to comment.