@@ -641,7 +641,7 @@ def import_plugin(self, modname: str, consider_entry_points: bool = False) -> No
641
641
except ImportError as e :
642
642
raise ImportError (
643
643
'Error importing plugin "{}": {}' .format (modname , str (e .args [0 ]))
644
- ).with_traceback (e .__traceback__ )
644
+ ).with_traceback (e .__traceback__ ) from e
645
645
646
646
except Skipped as e :
647
647
from _pytest .warnings import _issue_warning_captured
@@ -1130,8 +1130,8 @@ def getini(self, name: str):
1130
1130
def _getini (self , name : str ) -> Any :
1131
1131
try :
1132
1132
description , type , default = self ._parser ._inidict [name ]
1133
- except KeyError :
1134
- raise ValueError ("unknown configuration value: {!r}" .format (name ))
1133
+ except KeyError as e :
1134
+ raise ValueError ("unknown configuration value: {!r}" .format (name )) from e
1135
1135
override_value = self ._get_override_ini_value (name )
1136
1136
if override_value is None :
1137
1137
try :
@@ -1197,12 +1197,12 @@ def _get_override_ini_value(self, name: str) -> Optional[str]:
1197
1197
for ini_config in self ._override_ini :
1198
1198
try :
1199
1199
key , user_ini_value = ini_config .split ("=" , 1 )
1200
- except ValueError :
1200
+ except ValueError as e :
1201
1201
raise UsageError (
1202
1202
"-o/--override-ini expects option=value style (got: {!r})." .format (
1203
1203
ini_config
1204
1204
)
1205
- )
1205
+ ) from e
1206
1206
else :
1207
1207
if key == name :
1208
1208
value = user_ini_value
@@ -1223,14 +1223,14 @@ def getoption(self, name: str, default=notset, skip: bool = False):
1223
1223
if val is None and skip :
1224
1224
raise AttributeError (name )
1225
1225
return val
1226
- except AttributeError :
1226
+ except AttributeError as e :
1227
1227
if default is not notset :
1228
1228
return default
1229
1229
if skip :
1230
1230
import pytest
1231
1231
1232
1232
pytest .skip ("no {!r} option found" .format (name ))
1233
- raise ValueError ("no option named {!r}" .format (name ))
1233
+ raise ValueError ("no option named {!r}" .format (name )) from e
1234
1234
1235
1235
def getvalue (self , name , path = None ):
1236
1236
""" (deprecated, use getoption()) """
0 commit comments