Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix global configuration fallback in Jenkins runs #1466

Merged
merged 1 commit into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Chris Jerdonek
Chris Rose
Clark Boylan
Cyril Roelandt
Dane Hillard
David Staheli
Ederag
Eli Collins
Expand Down
1 change: 1 addition & 0 deletions docs/changelog/1428.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix fallback to global configuration when running in Jenkins. - by :user:`daneah`
4 changes: 2 additions & 2 deletions src/tox/_pytestplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
3 changes: 2 additions & 1 deletion src/tox/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,11 +991,12 @@ def line_of_default_to_zero(section, name=None):
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:
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2104,6 +2104,17 @@ def test_quiet(self, args, expected, newconfig):
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(
Expand Down