From 3f7223af443d68c18c90ffc84f58c5f0e9952cb0 Mon Sep 17 00:00:00 2001 From: feuillemorte Date: Tue, 27 Feb 2018 19:02:49 +0300 Subject: [PATCH] #3260 Fix pytest section in setup ini file --- _pytest/config.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/_pytest/config.py b/_pytest/config.py index d97771155..68d66ee2a 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -1327,10 +1327,17 @@ def determine_setup(inifile, args, warnfunc=None): dirs = get_dirs_from_args(args) if inifile: iniconfig = py.iniconfig.IniConfig(inifile) - try: - inicfg = iniconfig["pytest"] - except KeyError: - inicfg = None + is_cfg_file = '.cfg' in inifile + sections = ['tool:pytest', 'pytest'] if is_cfg_file else ['pytest'] + for section in sections: + try: + inicfg = iniconfig[section] + if is_cfg_file and section == 'pytest' and warnfunc: + from _pytest.deprecated import SETUP_CFG_PYTEST + warnfunc('C1', SETUP_CFG_PYTEST.replace('setup.cfg', inifile)) + break + except KeyError: + inicfg = None rootdir = get_common_ancestor(dirs) else: ancestor = get_common_ancestor(dirs)