Merge pull request #3267 from feuillemorte/3260-fix-pytest-section
#3260 fix pytest section
This commit is contained in:
commit
9fcbf57163
|
@ -1327,8 +1327,12 @@ def determine_setup(inifile, args, warnfunc=None):
|
||||||
dirs = get_dirs_from_args(args)
|
dirs = get_dirs_from_args(args)
|
||||||
if inifile:
|
if inifile:
|
||||||
iniconfig = py.iniconfig.IniConfig(inifile)
|
iniconfig = py.iniconfig.IniConfig(inifile)
|
||||||
|
is_cfg_file = str(inifile).endswith('.cfg')
|
||||||
|
sections = ['tool:pytest', 'pytest'] if is_cfg_file else ['pytest']
|
||||||
|
for section in sections:
|
||||||
try:
|
try:
|
||||||
inicfg = iniconfig["pytest"]
|
inicfg = iniconfig[section]
|
||||||
|
break
|
||||||
except KeyError:
|
except KeyError:
|
||||||
inicfg = None
|
inicfg = None
|
||||||
rootdir = get_common_ancestor(dirs)
|
rootdir = get_common_ancestor(dirs)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
``[tool:pytest]`` sections in ``*.cfg`` files passed by the ``-c`` option are now properly recognized.
|
|
@ -110,6 +110,13 @@ class TestConfigCmdlineParsing(object):
|
||||||
config = testdir.parseconfig("-c", "custom.cfg")
|
config = testdir.parseconfig("-c", "custom.cfg")
|
||||||
assert config.getini("custom") == "1"
|
assert config.getini("custom") == "1"
|
||||||
|
|
||||||
|
testdir.makefile(".cfg", custom_tool_pytest_section="""
|
||||||
|
[tool:pytest]
|
||||||
|
custom = 1
|
||||||
|
""")
|
||||||
|
config = testdir.parseconfig("-c", "custom_tool_pytest_section.cfg")
|
||||||
|
assert config.getini("custom") == "1"
|
||||||
|
|
||||||
def test_absolute_win32_path(self, testdir):
|
def test_absolute_win32_path(self, testdir):
|
||||||
temp_cfg_file = testdir.makefile(".cfg", custom="""
|
temp_cfg_file = testdir.makefile(".cfg", custom="""
|
||||||
[pytest]
|
[pytest]
|
||||||
|
|
Loading…
Reference in New Issue