Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,8 @@ def _is_pytest_base_url_loaded(pluginmanager: pytest.PytestPluginManager) -> boo
class _BaseUrlFallback:
# Provides the base_url fixture when pytest-base-url is not in use.
@pytest.fixture(scope="session")
def base_url(self, pytestconfig: Any) -> Optional[str]:
@classmethod
def base_url(cls, pytestconfig: Any) -> Optional[str]:
return (
pytestconfig.getoption("--base-url")
or pytestconfig.getini("base_url")
Expand Down
3 changes: 2 additions & 1 deletion pytest-playwright/pytest_playwright/pytest_playwright.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,8 @@ def _is_pytest_base_url_loaded(pluginmanager: pytest.PytestPluginManager) -> boo
class _BaseUrlFallback:
# Provides the base_url fixture when pytest-base-url is not in use.
@pytest.fixture(scope="session")
def base_url(self, pytestconfig: Any) -> Optional[str]:
@classmethod
def base_url(cls, pytestconfig: Any) -> Optional[str]:
return (
pytestconfig.getoption("--base-url")
or pytestconfig.getini("base_url")
Expand Down
21 changes: 21 additions & 0 deletions tests/test_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,27 @@ async def test_base_url(page, base_url):
result.assert_outcomes(passed=1)


def test_base_url_without_pytest_base_url_does_not_warn(
testdir: pytest.Testdir,
) -> None:
# https://github.com/microsoft/playwright-pytest/issues/341
testdir.makepyfile(
"""
def test_base_url(base_url):
assert base_url == "http://localhost"
"""
)
result = testdir.runpytest(
"-p",
"no:base_url",
"--base-url",
"http://localhost",
"-W",
"error::pytest.PytestDeprecationWarning",
)
result.assert_outcomes(passed=1)


def test_base_url_without_plugin_autoload(
testdir: pytest.Testdir,
test_server: HTTPTestServer,
Expand Down
21 changes: 21 additions & 0 deletions tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,27 @@ def test_base_url(page, base_url):
result.assert_outcomes(passed=1)


def test_base_url_without_pytest_base_url_does_not_warn(
testdir: pytest.Testdir,
) -> None:
# https://github.com/microsoft/playwright-pytest/issues/341
testdir.makepyfile(
"""
def test_base_url(base_url):
assert base_url == "http://localhost"
"""
)
result = testdir.runpytest(
"-p",
"no:base_url",
"--base-url",
"http://localhost",
"-W",
"error::pytest.PytestDeprecationWarning",
)
result.assert_outcomes(passed=1)


def test_base_url_without_plugin_autoload(
testdir: pytest.Testdir,
test_server: HTTPTestServer,
Expand Down
Loading