summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDane Hillard <github@danehillard.com>2019-11-28 04:21:57 -0500
committerBernát Gábor <bgabor8@bloomberg.net>2019-11-28 09:21:57 +0000
commit9ee972e7be07589c2ac09d5189c44e5943f0b51c (patch)
tree20c033b96aaf8892a0f33685b28412b28c713241
parentf324edf26de8fc6694d369195586e273b7997b0b (diff)
downloadtox-git-9ee972e7be07589c2ac09d5189c44e5943f0b51c.tar.gz
Fix global configuration fallback in Jenkins runs (#1466)
Fixes #1428 When running in Jenkins and using `setup.cfg`, tox would not fall back to the [tox:tox] configuration properly. This was due to how the fallback section name was calculated in this specific combination of characteristics. on-behalf-of: @ithaka <dane.hillard@ithaka.org>
-rw-r--r--CONTRIBUTORS1
-rw-r--r--docs/changelog/1428.bugfix.rst1
-rw-r--r--src/tox/_pytestplugin.py4
-rw-r--r--src/tox/config/__init__.py3
-rw-r--r--tests/unit/config/test_config.py11
5 files changed, 17 insertions, 3 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 24169944..54209380 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -19,6 +19,7 @@ Chris Jerdonek
Chris Rose
Clark Boylan
Cyril Roelandt
+Dane Hillard
David Staheli
Ederag
Eli Collins
diff --git a/docs/changelog/1428.bugfix.rst b/docs/changelog/1428.bugfix.rst
new file mode 100644
index 00000000..8946cb18
--- /dev/null
+++ b/docs/changelog/1428.bugfix.rst
@@ -0,0 +1 @@
+Fix fallback to global configuration when running in Jenkins. - by :user:`daneah`
diff --git a/src/tox/_pytestplugin.py b/src/tox/_pytestplugin.py
index b22f0732..7e9d94ab 100644
--- a/src/tox/_pytestplugin.py
+++ b/src/tox/_pytestplugin.py
@@ -102,12 +102,12 @@ def check_os_environ_stable():
@pytest.fixture(name="newconfig")
def create_new_config_file(tmpdir):
- def create_new_config_file_(args, source=None, plugins=()):
+ def create_new_config_file_(args, source=None, plugins=(), filename="tox.ini"):
if source is None:
source = args
args = []
s = textwrap.dedent(source)
- p = tmpdir.join("tox.ini")
+ p = tmpdir.join(filename)
p.write(s)
tox.session.setup_reporter(args)
with tmpdir.as_cwd():
diff --git a/src/tox/config/__init__.py b/src/tox/config/__init__.py
index fe93d25c..d80da5ff 100644
--- a/src/tox/config/__init__.py
+++ b/src/tox/config/__init__.py
@@ -991,11 +991,12 @@ class ParseIni(object):
self.config = config
prefix = "tox" if ini_path.basename == "setup.cfg" else None
+ fallbacksection = "tox:tox" if ini_path.basename == "setup.cfg" else "tox"
context_name = getcontextname()
if context_name == "jenkins":
reader = SectionReader(
- "tox:jenkins", self._cfg, prefix=prefix, fallbacksections=["tox"]
+ "tox:jenkins", self._cfg, prefix=prefix, fallbacksections=[fallbacksection]
)
dist_share_default = "{toxworkdir}/distshare"
elif not context_name:
diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py
index f90aa964..9fd5b23c 100644
--- a/tests/unit/config/test_config.py
+++ b/tests/unit/config/test_config.py
@@ -2104,6 +2104,17 @@ class TestGlobalOptions:
config = newconfig(args, "")
assert config.option.quiet_level == expected
+ def test_substitution_jenkins_global(self, monkeypatch, newconfig):
+ monkeypatch.setenv("HUDSON_URL", "xyz")
+ config = newconfig(
+ """
+ [tox:tox]
+ envlist = py37
+ """,
+ filename="setup.cfg",
+ )
+ assert "py37" in config.envconfigs
+
def test_substitution_jenkins_default(self, monkeypatch, newconfig):
monkeypatch.setenv("HUDSON_URL", "xyz")
config = newconfig(