Skip to content
Open
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.9.0
rev: 26.1.0
hooks:
- id: black
args: [--safe, --quiet]
Expand Down
36 changes: 12 additions & 24 deletions tests/test_base_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,23 @@


def test_fixture(testdir):
testdir.makepyfile(
"""
testdir.makepyfile("""
import pytest
@pytest.fixture(scope='session')
def base_url():
return 'foo'
def test_fixture(base_url):
assert base_url == 'foo'
"""
)
""")
result = testdir.runpytest()
assert result.ret == 0


def test_cli(testdir):
testdir.makepyfile(
"""
testdir.makepyfile("""
def test_funcarg(base_url):
assert base_url == 'foo'
"""
)
""")
result = testdir.runpytest("--base-url", "foo")
assert result.ret == 0

Expand All @@ -37,14 +33,12 @@ def test_config(testdir):
base_url=foo
""",
)
testdir.makepyfile(
"""
testdir.makepyfile("""
def test_config(request, base_url):
assert request.config.getvalue('base_url') == 'foo'
assert request.config.getini('base_url') == 'foo'
assert base_url == 'foo'
"""
)
""")
result = testdir.runpytest()
assert result.ret == 0

Expand All @@ -57,40 +51,34 @@ def test_skip_config(testdir):
base_url=foo
""",
)
testdir.makepyfile(
"""
testdir.makepyfile("""
import pytest
@pytest.mark.skipif(
"config.getoption('base_url') == 'foo'",
reason='skip')
def test_skip_config(): pass
"""
)
""")
result = testdir.runpytest()
assert result.ret == 0


def test_env_var_set(testdir, monkeypatch):
testdir.makepyfile(
"""
testdir.makepyfile("""
def test_config(request, base_url):
assert request.config.getvalue('base_url')
assert base_url == 'yeehaw'
"""
)
""")
monkeypatch.setenv("PYTEST_BASE_URL", "yeehaw")
reprec = testdir.inline_run()
passed, skipped, failed = reprec.listoutcomes()
assert len(passed) == 1


def test_metadata(testdir, monkeypatch):
testdir.makepyfile(
"""
testdir.makepyfile("""
def test_config(metadata):
assert metadata["Base URL"] == 'yeehaw'
"""
)
""")
monkeypatch.setenv("PYTEST_BASE_URL", "yeehaw")
reprec = testdir.inline_run()
passed, skipped, failed = reprec.listoutcomes()
Expand Down