Skip to content

Commit

Permalink
fix: report not valid browser names as error (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Aug 5, 2020
1 parent aa888c1 commit 2ecae21
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pytest_playwright/pytest_playwright.py
Expand Up @@ -25,6 +25,11 @@
def pytest_generate_tests(metafunc: Any) -> None:
if "browser_name" in metafunc.fixturenames:
browsers = metafunc.config.option.browser or ["chromium"]
for browser in browsers:
if browser not in ["chromium", "firefox", "webkit"]:
raise ValueError(
f"'{browser}' is not allowed. Only chromium, firefox, or webkit are valid browser names."
)
metafunc.parametrize("browser_name", browsers, scope="session")


Expand Down
12 changes: 12 additions & 0 deletions tests/test_playwright.py
Expand Up @@ -165,3 +165,15 @@ def test_base_url(page, browser_name):
)
result = testdir.runpytest("--browser", "chromium", "--headful")
result.assert_outcomes(passed=1)


def test_invalid_browser_name(testdir: Any) -> None:
testdir.makepyfile(
"""
def test_base_url(page):
pass
"""
)
result = testdir.runpytest("--browser", "test123")
result.assert_outcomes(errors=1)
assert "'test123' is not allowed" in "\n".join(result.outlines)

0 comments on commit 2ecae21

Please sign in to comment.