File tree Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,11 @@ You can specify the base URL using a `configuration file`_:
69
69
[pytest]
70
70
base_url = http://www.example.com
71
71
72
+ Using an Environment Variable
73
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
74
+
75
+ You can specify the base URL by setting the ``PYTEST_BASE_URL `` environment variable.
76
+
72
77
Using a Fixture
73
78
^^^^^^^^^^^^^^^
74
79
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ def pytest_addoption(parser):
45
45
parser .addoption (
46
46
'--base-url' ,
47
47
metavar = 'url' ,
48
+ default = os .getenv ('PYTEST_BASE_URL' , None ),
48
49
help = 'base url for the application under test.' )
49
50
parser .addoption (
50
51
'--verify-base-url' ,
Original file line number Diff line number Diff line change @@ -54,3 +54,15 @@ def test_skip_config(): pass
54
54
""" )
55
55
result = testdir .runpytest ()
56
56
assert result .ret == 0
57
+
58
+
59
+ def test_env_var_set (testdir , monkeypatch ):
60
+ testdir .makepyfile ("""
61
+ def test_config(request, base_url):
62
+ assert request.config.getvalue('base_url')
63
+ assert base_url == 'yeehaw'
64
+ """ )
65
+ monkeypatch .setenv ('PYTEST_BASE_URL' , 'yeehaw' )
66
+ reprec = testdir .inline_run ()
67
+ passed , skipped , failed = reprec .listoutcomes ()
68
+ assert len (passed ) == 1
You can’t perform that action at this time.
0 commit comments