Skip to content

Commit

Permalink
Merge pull request #32 from p13773/issue_29
Browse files Browse the repository at this point in the history
replace request._fixturedefs by request._fixture_defs, solve issue #29
  • Loading branch information
bubenkoff committed Oct 18, 2016
2 parents 5ce7849 + f8aaf20 commit 532835d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
11 changes: 8 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
sudo: false
language: python
# enable Python 3.5 on travis until it will be pre-installed
python: 3.5
env:
matrix:
- TESTENV=py26
- TESTENV=py27
- TESTENV=py34
- TESTENV=py27-pytest2
- TESTENV=py34-pytest2
- TESTENV=py35-pytest2
- TESTENV=py27-pytest3
- TESTENV=py34-pytest3
- TESTENV=py35-pytest3
install:
- pip install tox
script: tox -e $TESTENV
Expand Down
5 changes: 4 additions & 1 deletion pytest_factoryboy/fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ def attributes(cls, create=False, extra=None):
# Create model fixture instance
instance = Factory(**data)
request._fixturedef.cached_result = (instance, None, None)
request._fixturedefs[request.fixturename] = request._fixturedef
if hasattr(request, '_fixture_defs'):
request._fixture_defs[request.fixturename] = request._fixturedef
else:
request._fixturedefs[request.fixturename] = request._fixturedef

# Defer post-generation declarations
related = []
Expand Down
6 changes: 5 additions & 1 deletion pytest_factoryboy/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ def get_deps(self, request, fixture, deps=None):

def get_current_deps(self, request):
deps = set()
if hasattr(request, '_fixture_defs'):
fixture_defs = request._fixture_defs
else:
fixture_defs = request._fixturedefs
while hasattr(request, '_parent_request'):
if request.fixturename and request.fixturename not in request._fixturedefs:
if request.fixturename and request.fixturename not in fixture_defs:
deps.add(request.fixturename)
request = request._parent_request
return deps
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"Topic :: Utilities",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3"
] + [("Programming Language :: Python :: %s" % x) for x in "2.6 2.7 3.0 3.1 3.2 3.3 3.4".split()],
] + [("Programming Language :: Python :: %s" % x) for x in "2.7 3.0 3.1 3.2 3.3 3.4 3.5".split()],
install_requires=[
"inflection",
"factory_boy",
Expand Down
5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
[tox]
distshare = {homedir}/.tox/distshare
envlist = py26,py27,py34
envlist = py{27,34,35}-pytest{2,3}


[testenv]
commands = py.test --junitxml={envlogdir}/junit-{envname}.xml pytest_factoryboy tests
deps = -r{toxinidir}/requirements-testing.txt
pytest2: pytest<3.0
pytest3: pytest>3.0

[pytest]
addopts = -vv -l --pep8
Expand Down

0 comments on commit 532835d

Please sign in to comment.