1 new commit in pytest: https://bitbucket.org/hpk42/pytest/commits/46d5ac0ba396/ Changeset: 46d5ac0ba396 User: flub Date: 2015-02-09 16:33:36+00:00 Summary: Merged in davehunt/pytest/env-addopts (pull request #241)
Support setting configuration using the PYTEST_ADDOPTS environment variable Affected #: 5 files diff -r a7d80ee0a5a24bd0c9f9d3b3997f0a7f5bc10189 -r 46d5ac0ba396af887969a3cc9940fccba5ff1955 AUTHORS --- a/AUTHORS +++ b/AUTHORS @@ -46,3 +46,4 @@ David Mohr Nicolas Delaby Tom Viner +Dave Hunt diff -r a7d80ee0a5a24bd0c9f9d3b3997f0a7f5bc10189 -r 46d5ac0ba396af887969a3cc9940fccba5ff1955 CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ 2.7.0.dev (compared to 2.6.4) ----------------------------- +- add ability to set command line options by environment variable PYTEST_ADDOPTS. + - fix issue655: work around different ways that cause python2/3 to leak sys.exc_info into fixtures/tests causing failures in 3rd party code diff -r a7d80ee0a5a24bd0c9f9d3b3997f0a7f5bc10189 -r 46d5ac0ba396af887969a3cc9940fccba5ff1955 _pytest/config.py --- a/_pytest/config.py +++ b/_pytest/config.py @@ -705,6 +705,7 @@ def _preparse(self, args, addopts=True): self._initini(args) if addopts: + args[:] = shlex.split(os.environ.get('PYTEST_ADDOPTS', '')) + args args[:] = self.getini("addopts") + args self._checkversion() self.pluginmanager.consider_preparse(args) diff -r a7d80ee0a5a24bd0c9f9d3b3997f0a7f5bc10189 -r 46d5ac0ba396af887969a3cc9940fccba5ff1955 doc/en/customize.txt --- a/doc/en/customize.txt +++ b/doc/en/customize.txt @@ -60,6 +60,11 @@ [pytest] addopts = -rsxX -q +Alternatively, you can set a PYTEST_ADDOPTS environment variable to add command +line options while the environment is in use:: + + export PYTEST_ADDOPTS="-rsxX -q" + From now on, running ``pytest`` will add the specified options. Builtin configuration file options diff -r a7d80ee0a5a24bd0c9f9d3b3997f0a7f5bc10189 -r 46d5ac0ba396af887969a3cc9940fccba5ff1955 testing/test_config.py --- a/testing/test_config.py +++ b/testing/test_config.py @@ -18,12 +18,16 @@ def test_getcfg_empty_path(self, tmpdir): getcfg([''], ['setup.cfg']) #happens on py.test "" - def test_append_parse_args(self, testdir, tmpdir): + def test_append_parse_args(self, testdir, tmpdir, monkeypatch): + monkeypatch.setenv('PYTEST_ADDOPTS', '--color no -rs --tb="short"') tmpdir.join("setup.cfg").write(py.code.Source(""" [pytest] addopts = --verbose """)) config = testdir.parseconfig(tmpdir) + assert config.option.color == 'no' + assert config.option.reportchars == 's' + assert config.option.tbstyle == 'short' assert config.option.verbose #config = testdir.Config() #args = [tmpdir,] Repository URL: https://bitbucket.org/hpk42/pytest/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. _______________________________________________ pytest-commit mailing list pytest-commit@python.org https://mail.python.org/mailman/listinfo/pytest-commit