Import upstream version 2.0.3
Kali Janitor
3 years ago
0 | 0 |
Changelog
|
1 | 1 |
=========
|
|
2 |
|
|
3 |
2.0.3
|
|
4 |
-----
|
|
5 |
|
|
6 |
- Fix compatibility with pytest 5.
|
|
7 |
|
2 | 8 |
|
3 | 9 |
2.0.2
|
4 | 10 |
-----
|
4 | 4 |
:target: https://pypi.python.org/pypi/pytest-factoryboy
|
5 | 5 |
.. image:: https://img.shields.io/pypi/pyversions/pytest-factoryboy.svg
|
6 | 6 |
:target: https://pypi.python.org/pypi/pytest-factoryboy
|
7 | |
.. image:: https://img.shields.io/coveralls/pytest-dev/pytest-factoryboy/master.svg
|
8 | |
:target: https://coveralls.io/r/pytest-dev/pytest-factoryboy
|
9 | 7 |
.. image:: https://travis-ci.org/pytest-dev/pytest-factoryboy.svg?branch=master
|
10 | 8 |
:target: https://travis-ci.org/pytest-dev/pytest-factoryboy
|
11 | 9 |
.. image:: https://readthedocs.org/projects/pytest-factoryboy/badge/?version=latest
|
|
74 | 72 |
from pytest_factoryboy import register
|
75 | 73 |
|
76 | 74 |
@register
|
77 | |
class AuthorFactory(Factory):
|
|
75 |
class AuthorFactory(factory.Factory):
|
78 | 76 |
|
79 | 77 |
class Meta:
|
80 | 78 |
model = Author
|
0 | 0 |
"""pytest-factoryboy public API."""
|
1 | 1 |
from .fixture import register, LazyFixture
|
2 | 2 |
|
3 | |
__version__ = '2.0.2'
|
|
3 |
__version__ = '2.0.3'
|
4 | 4 |
|
5 | 5 |
|
6 | 6 |
__all__ = [
|
0 | 0 |
"""Factory boy fixture integration."""
|
1 | 1 |
|
2 | 2 |
import sys
|
3 | |
import inspect
|
4 | 3 |
|
5 | 4 |
import factory
|
6 | 5 |
import factory.builder
|
|
9 | 8 |
import inflection
|
10 | 9 |
import pytest
|
11 | 10 |
|
|
11 |
from inspect import getmodule
|
|
12 |
|
|
13 |
if sys.version_info > (3, 0):
|
|
14 |
from inspect import signature
|
|
15 |
else:
|
|
16 |
from funcsigs import signature
|
12 | 17 |
|
13 | 18 |
SEPARATOR = "__"
|
14 | 19 |
|
|
315 | 320 |
def get_caller_module(depth=2):
|
316 | 321 |
"""Get the module of the caller."""
|
317 | 322 |
frame = sys._getframe(depth)
|
318 | |
module = inspect.getmodule(frame)
|
|
323 |
module = getmodule(frame)
|
319 | 324 |
# Happens when there's no __init__.py in the folder
|
320 | 325 |
if module is None:
|
321 | 326 |
return get_caller_module(depth=depth) # pragma: no cover
|
|
332 | 337 |
"""
|
333 | 338 |
self.fixture = fixture
|
334 | 339 |
if callable(self.fixture):
|
335 | |
self.args = list(inspect.getargspec(self.fixture).args)
|
|
340 |
params = signature(self.fixture).parameters.values()
|
|
341 |
self.args = [
|
|
342 |
param.name for param in params
|
|
343 |
if param.kind == param.POSITIONAL_OR_KEYWORD
|
|
344 |
]
|
336 | 345 |
else:
|
337 | 346 |
self.args = [self.fixture]
|
338 | 347 |
|
112 | 112 |
def pytest_addhooks(pluginmanager):
|
113 | 113 |
"""Register plugin hooks."""
|
114 | 114 |
from pytest_factoryboy import hooks
|
115 | |
# addhooks is for older py.test and deprecated; replaced by add_hookspecs
|
116 | |
add_hookspecs = getattr(pluginmanager, 'add_hookspecs', pluginmanager.addhooks)
|
117 | |
add_hookspecs(hooks)
|
|
115 |
pluginmanager.add_hookspecs(hooks)
|
118 | 116 |
|
119 | 117 |
|
120 | 118 |
def pytest_generate_tests(metafunc):
|
|
123 | 121 |
fixturedef = arg2fixturedef[-1]
|
124 | 122 |
related.extend(getattr(fixturedef.func, "_factoryboy_related", []))
|
125 | 123 |
|
126 | |
metafunc.funcargnames.extend(related)
|
|
124 |
metafunc.fixturenames.extend(related)
|
37 | 37 |
"Topic :: Utilities",
|
38 | 38 |
"Programming Language :: Python :: 2",
|
39 | 39 |
"Programming Language :: Python :: 3"
|
40 | |
] + [("Programming Language :: Python :: %s" % x) for x in "2.7 3.0 3.1 3.2 3.3 3.4 3.5".split()],
|
|
40 |
] + [("Programming Language :: Python :: %s" % x) for x in "2.7 3.4 3.5 3.6 3.7".split()],
|
41 | 41 |
install_requires=[
|
42 | 42 |
"inflection",
|
43 | 43 |
"factory_boy>=2.10.0",
|
44 | 44 |
"pytest>=3.3.2",
|
|
45 |
'funcsigs;python_version<"3.0"',
|
45 | 46 |
],
|
46 | 47 |
# the following makes a plugin available to py.test
|
47 | 48 |
entry_points={
|
0 | 0 |
[tox]
|
1 | 1 |
distshare = {homedir}/.tox/distshare
|
2 | |
envlist = py{27,34,35}-pytest{2,3}
|
3 | |
|
|
2 |
envlist = py27-pytest{36,37,38,39,310,4,41,42,43,44,45,46},
|
|
3 |
py37-pytest{36,37,38,39,310,4,41,42,43,44,45,46,5,latest},
|
|
4 |
py{35,36}-pytestlatest
|
4 | 5 |
|
5 | 6 |
[testenv]
|
6 | |
commands = py.test --junitxml={envlogdir}/junit-{envname}.xml {posargs:tests}
|
7 | |
deps = -r{toxinidir}/requirements-testing.txt
|
8 | |
pytest2: pytest<3.0
|
9 | |
pytest3: pytest>3.0
|
|
7 |
commands = pytest --junitxml={envlogdir}/junit-{envname}.xml {posargs:tests}
|
|
8 |
deps =
|
|
9 |
pytestlatest: pytest
|
|
10 |
pytest5: pytest~=5.0.0
|
|
11 |
pytest46: pytest~=4.6.0
|
|
12 |
pytest45: pytest~=4.5.0
|
|
13 |
pytest44: pytest~=4.4.0
|
|
14 |
pytest43: pytest~=4.3.0
|
|
15 |
pytest42: pytest~=4.2.0
|
|
16 |
pytest41: pytest~=4.1.0
|
|
17 |
pytest4: pytest~=4.0.0
|
|
18 |
pytest310: pytest~=3.10.0
|
|
19 |
pytest39: pytest~=3.9.0
|
|
20 |
pytest38: pytest~=3.8.0
|
|
21 |
pytest37: pytest~=3.7.0
|
|
22 |
pytest36: pytest~=3.6.0
|
|
23 |
|
|
24 |
-r{toxinidir}/requirements-testing.txt
|
10 | 25 |
|
11 | 26 |
[pytest]
|
12 | 27 |
addopts = -vv -l --pep8
|