diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 72d0c9041e0..a4a1f974d07 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -778,7 +778,6 @@ def __init__(self, pluginmanager, *, invocation_params=None) -> None: ) self.option = argparse.Namespace() - self._nondefault_options = set() # type: Set[str] self.invocation_params = invocation_params _a = FILE_OR_DIR @@ -892,10 +891,9 @@ def _processopt(self, opt: "Argument") -> None: for name in opt._short_opts + opt._long_opts: self._opt2dest[name] = opt.dest - if hasattr(self.option, opt.dest): - self._nondefault_options.add(opt.dest) - elif hasattr(opt, "default"): - setattr(self.option, opt.dest, opt.default) + if hasattr(opt, "default"): + if not hasattr(self.option, opt.dest): + setattr(self.option, opt.dest, opt.default) @hookimpl(trylast=True) def pytest_load_initial_conftests(self, early_config): diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index 1bc8b9bb393..854b7328f5c 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -335,11 +335,11 @@ def _repr_failure_py( return excinfo.value.formatrepr() # XXX should excinfo.getrepr record all data and toterminal() process it? + # XXX: does not distinguish between default/unset and --tb=auto. tbstyle = self.config.option.tbstyle verbosity = self.config.option.verbose if fulltrace: - tbstyle_given = "tbstyle" in self.config._nondefault_options - style = tbstyle if tbstyle_given else "long" # type: _TracebackStyle + style = "long" if tbstyle == "auto" else tbstyle # type: _TracebackStyle else: if tbstyle == "auto": if default_style is None: