Skip to content

Support modern pytest and pytest-django #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ nosetests.xml
coverage.xml
*,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ python:

sudo: false

cache: pip
install: make requirements

script:
Expand Down
13 changes: 11 additions & 2 deletions pytest_django_ordering/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@

def pytest_collection_modifyitems(items):
def get_marker_transaction(test):
marker = test.get_marker('django_db')
try:
marker = test.get_closest_marker('django_db')
except AttributeError:
# pytest < 3.6.0
marker = test.get_marker('django_db')

if marker:
validate_django_db(marker)
return marker.transaction
try:
return marker.kwargs.get("transaction")
except AttributeError:
# pytest-django < 3.3.0
return marker.transaction

return None

Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
flake8==3.2.1
pytest==3.0.6
flake8
-e .