Skip to content
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

Django 1.9 compatibility #522

Merged
merged 3 commits into from
Jul 26, 2016
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
8 changes: 4 additions & 4 deletions lettuce/django/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _filter_bultins(module):
def _filter_configured_apps(module):
"returns only those apps that are in django.conf.settings.LETTUCE_APPS"
app_found = True
if hasattr(settings, 'LETTUCE_APPS') and isinstance(settings.LETTUCE_APPS, tuple):
if hasattr(settings, 'LETTUCE_APPS') and isinstance(settings.LETTUCE_APPS, (list, tuple)):
app_found = False
for appname in settings.LETTUCE_APPS:
if module.__name__.startswith(appname):
Expand All @@ -44,7 +44,7 @@ def _filter_configured_apps(module):
def _filter_configured_avoids(module):
"returns apps that are not within django.conf.settings.LETTUCE_AVOID_APPS"
run_app = False
if hasattr(settings, 'LETTUCE_AVOID_APPS') and isinstance(settings.LETTUCE_AVOID_APPS, tuple):
if hasattr(settings, 'LETTUCE_AVOID_APPS') and isinstance(settings.LETTUCE_AVOID_APPS, (list, tuple)):
for appname in settings.LETTUCE_AVOID_APPS:
if module.__name__.startswith(appname):
run_app = True
Expand Down Expand Up @@ -73,7 +73,7 @@ def harvest_lettuces(only_the_apps=None, avoid_apps=None, path="features"):

apps = get_apps()

if isinstance(only_the_apps, tuple) and any(only_the_apps):
if isinstance(only_the_apps, (list, tuple)) and any(only_the_apps):

def _filter_only_specified(module):
return module.__name__ in only_the_apps
Expand All @@ -83,7 +83,7 @@ def _filter_only_specified(module):
apps = filter(_filter_configured_apps, apps)
apps = filter(_filter_configured_avoids, apps)

if isinstance(avoid_apps, tuple) and any(avoid_apps):
if isinstance(avoid_apps, (list, tuple)) and any(avoid_apps):

def _filter_avoid(module):
return module.__name__ not in avoid_apps
Expand Down
2 changes: 1 addition & 1 deletion lettuce/django/management/commands/harvest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
class Command(BaseCommand):
help = u'Run lettuce tests all along installed apps'
args = '[PATH to feature file or folder]'
requires_model_validation = False
requires_model_validation = requires_system_checks = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change breaks the harvest command - see #525

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(for Django versions < 1.9)


option_list = BaseCommand.option_list + (
make_option('-a', '--apps', action='store', dest='apps', default='',
Expand Down
6 changes: 5 additions & 1 deletion lettuce/django/steps/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
from django.core.management import call_command
from django.core.management.color import no_style
from django.db import connection
from django.db.models.loading import get_models
try:
from django.db.models.loading import get_models
except ImportError:
from django.apps import apps
get_models = apps.get_models
from django.utils.functional import curry
from functools import wraps

Expand Down