Skip to content

Commit

Permalink
chore: cleanup CLI browser validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Aug 8, 2021
1 parent 0988335 commit 7316564
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
9 changes: 2 additions & 7 deletions pytest_playwright/pytest_playwright.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ def delete_output_dir(pytestconfig: Any) -> None:
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 Expand Up @@ -172,7 +167,6 @@ def browser_type(playwright: Playwright, browser_name: str) -> BrowserType:

@pytest.fixture(scope="session")
def launch_browser(
playwright: Playwright,
browser_type_launch_args: Dict,
browser_type: BrowserType,
) -> Callable[..., Browser]:
Expand Down Expand Up @@ -316,6 +310,7 @@ def pytest_addoption(parser: Any) -> None:
action="append",
default=[],
help="Browser engine which should be used",
choices=["chromium", "firefox", "webkit"],
)
group.addoption(
"--headed",
Expand All @@ -333,7 +328,7 @@ def pytest_addoption(parser: Any) -> None:
"--slowmo",
default=0,
type=int,
help="Run tests in slow mo",
help="Run tests with slow mo",
)
group.addoption(
"--device", default=None, action="store", help="Device to be emulated."
Expand Down
3 changes: 1 addition & 2 deletions tests/test_playwright.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,7 @@ def test_base_url(page):
"""
)
result = testdir.runpytest("--browser", "test123")
result.assert_outcomes(errors=1)
assert "'test123' is not allowed" in "\n".join(result.outlines)
assert any(["--browser: invalid choice" in line for line in result.errlines])


def test_django(testdir: pytest.Testdir) -> None:
Expand Down

0 comments on commit 7316564

Please sign in to comment.