File tree 2 files changed +13
-3
lines changed
2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 1
1
"""Factory boy fixture integration."""
2
2
3
3
import sys
4
- import inspect
5
4
6
5
import factory
7
6
import factory .builder
10
9
import inflection
11
10
import pytest
12
11
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
13
18
14
19
SEPARATOR = "__"
15
20
@@ -316,7 +321,7 @@ def subfactory_fixture(request, factory_class):
316
321
def get_caller_module (depth = 2 ):
317
322
"""Get the module of the caller."""
318
323
frame = sys ._getframe (depth )
319
- module = inspect . getmodule (frame )
324
+ module = getmodule (frame )
320
325
# Happens when there's no __init__.py in the folder
321
326
if module is None :
322
327
return get_caller_module (depth = depth ) # pragma: no cover
@@ -333,7 +338,11 @@ def __init__(self, fixture):
333
338
"""
334
339
self .fixture = fixture
335
340
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
+ ]
337
346
else :
338
347
self .args = [self .fixture ]
339
348
Original file line number Diff line number Diff line change 43
43
"inflection" ,
44
44
"factory_boy>=2.10.0" ,
45
45
"pytest>=3.3.2" ,
46
+ 'funcsigs;python_version<"3.0"' ,
46
47
],
47
48
# the following makes a plugin available to py.test
48
49
entry_points = {
You can’t perform that action at this time.
0 commit comments