File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 11"""Factory boy fixture integration."""
22
33import sys
4- import inspect
54
65import factory
76import factory .builder
109import inflection
1110import pytest
1211
12+ from inspect import getmodule
13+
14+ if sys .version_info > (3 , 0 ):
15+ from inspect import signature
16+ else :
17+ from funcsigs import signature
1318
1419SEPARATOR = "__"
1520
@@ -316,7 +321,7 @@ def subfactory_fixture(request, factory_class):
316321def get_caller_module (depth = 2 ):
317322 """Get the module of the caller."""
318323 frame = sys ._getframe (depth )
319- module = inspect . getmodule (frame )
324+ module = getmodule (frame )
320325 # Happens when there's no __init__.py in the folder
321326 if module is None :
322327 return get_caller_module (depth = depth ) # pragma: no cover
@@ -333,7 +338,11 @@ def __init__(self, fixture):
333338 """
334339 self .fixture = fixture
335340 if callable (self .fixture ):
336- self .args = list (inspect .getargspec (self .fixture ).args )
341+ params = signature (self .fixture ).parameters .values ()
342+ self .args = [
343+ param .name for param in params
344+ if param .kind == param .POSITIONAL_OR_KEYWORD
345+ ]
337346 else :
338347 self .args = [self .fixture ]
339348
Original file line number Diff line number Diff line change 4343 "inflection" ,
4444 "factory_boy>=2.10.0" ,
4545 "pytest>=3.3.2" ,
46+ 'funcsigs;python_version<"3.0"' ,
4647 ],
4748 # the following makes a plugin available to py.test
4849 entry_points = {
You can’t perform that action at this time.
0 commit comments