change try/except to sys.module.get and a conditional
This commit is contained in:
parent
3388d82c1c
commit
c3f4eb6d57
|
@ -1836,12 +1836,12 @@ def getfuncargnames(function, startindex=None):
|
||||||
if startindex is None:
|
if startindex is None:
|
||||||
startindex = inspect.ismethod(function) and 1 or 0
|
startindex = inspect.ismethod(function) and 1 or 0
|
||||||
if realfunction != function:
|
if realfunction != function:
|
||||||
try:
|
mock_default = sys.modules.get('mock.DEFAULT')
|
||||||
from mock import DEFAULT
|
if mock_default:
|
||||||
for patching in getattr(function, "patchings", []):
|
for patching in getattr(function, "patchings", []):
|
||||||
if not patching.attribute_name and patching.new is DEFAULT:
|
if not patching.attribute_name and patching.new is DEFAULT:
|
||||||
startindex += 1
|
startindex += 1
|
||||||
except ImportError:
|
else:
|
||||||
startindex += len(getattr(function, "patchings", []))
|
startindex += len(getattr(function, "patchings", []))
|
||||||
function = realfunction
|
function = realfunction
|
||||||
argnames = inspect.getargs(py.code.getrawcode(function))[0]
|
argnames = inspect.getargs(py.code.getrawcode(function))[0]
|
||||||
|
|
Loading…
Reference in New Issue