Support setting configuration using the PYTEST_ADDOPTS environment variable.
--HG-- branch : env-addopts
This commit is contained in:
parent
394367e1d2
commit
7325a5fe2e
|
@ -705,6 +705,8 @@ class Config(object):
|
||||||
def _preparse(self, args, addopts=True):
|
def _preparse(self, args, addopts=True):
|
||||||
self._initini(args)
|
self._initini(args)
|
||||||
if addopts:
|
if addopts:
|
||||||
|
env_addopts = os.environ.get('PYTEST_ADDOPTS', '')
|
||||||
|
args[:] = env_addopts.replace('"', '').split() + args
|
||||||
args[:] = self.getini("addopts") + args
|
args[:] = self.getini("addopts") + args
|
||||||
self._checkversion()
|
self._checkversion()
|
||||||
self.pluginmanager.consider_preparse(args)
|
self.pluginmanager.consider_preparse(args)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import os
|
||||||
|
|
||||||
import py, pytest
|
import py, pytest
|
||||||
|
|
||||||
from _pytest.config import getcfg
|
from _pytest.config import getcfg
|
||||||
|
@ -19,11 +21,16 @@ class TestParseIni:
|
||||||
getcfg([''], ['setup.cfg']) #happens on py.test ""
|
getcfg([''], ['setup.cfg']) #happens on py.test ""
|
||||||
|
|
||||||
def test_append_parse_args(self, testdir, tmpdir):
|
def test_append_parse_args(self, testdir, tmpdir):
|
||||||
|
os.environ['PYTEST_ADDOPTS'] = '--color no -rs --tb="short"'
|
||||||
tmpdir.join("setup.cfg").write(py.code.Source("""
|
tmpdir.join("setup.cfg").write(py.code.Source("""
|
||||||
[pytest]
|
[pytest]
|
||||||
addopts = --verbose
|
addopts = --verbose
|
||||||
"""))
|
"""))
|
||||||
config = testdir.parseconfig(tmpdir)
|
config = testdir.parseconfig(tmpdir)
|
||||||
|
del os.environ['PYTEST_ADDOPTS']
|
||||||
|
assert config.option.color == 'no'
|
||||||
|
assert config.option.reportchars == 's'
|
||||||
|
assert config.option.tbstyle == 'short'
|
||||||
assert config.option.verbose
|
assert config.option.verbose
|
||||||
#config = testdir.Config()
|
#config = testdir.Config()
|
||||||
#args = [tmpdir,]
|
#args = [tmpdir,]
|
||||||
|
|
Loading…
Reference in New Issue