From 493c95459d715ed18447cf9238b4901d5280743d Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 26 Aug 2019 15:30:22 +0100 Subject: [PATCH] django22: Handle changes in management commands The management commands gained a '--force-color' argument in Django 2.2 [1]. [1] https://github.com/django/django/commit/5195b99e2c3 Change-Id: I6729c3c7acbf42af91575eb83908412cf532ffd7 Signed-off-by: Stephen Finucane --- .../management/commands/test_startdash.py | 21 +++++++++++++------ .../management/commands/test_startpanel.py | 20 +++++++++++++----- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/horizon/test/unit/management/commands/test_startdash.py b/horizon/test/unit/management/commands/test_startdash.py index 2b2a51446b..9c11be24e0 100644 --- a/horizon/test/unit/management/commands/test_startdash.py +++ b/horizon/test/unit/management/commands/test_startdash.py @@ -14,6 +14,7 @@ import mock +import django from django.core.management import call_command from django.core.management import CommandError from django.test import TestCase @@ -29,9 +30,17 @@ class CommandsTestCase(TestCase): def test_startdash_usage_correct(self, handle): call_command('startdash', 'test_dash') - handle.assert_called_with(dash_name='test_dash', - extensions=["py", "tmpl", "html", "js", - "css"], - files=[], no_color=False, pythonpath=None, - settings=None, skip_checks=True, target=None, - template=None, traceback=False, verbosity=1) + if django.VERSION >= (2, 2): + handle.assert_called_with( + dash_name='test_dash', + extensions=["py", "tmpl", "html", "js", "css"], + files=[], force_color=False, no_color=False, pythonpath=None, + settings=None, skip_checks=True, target=None, template=None, + traceback=False, verbosity=1) + else: + handle.assert_called_with( + dash_name='test_dash', + extensions=["py", "tmpl", "html", "js", "css"], + files=[], no_color=False, pythonpath=None, + settings=None, skip_checks=True, target=None, template=None, + traceback=False, verbosity=1) diff --git a/horizon/test/unit/management/commands/test_startpanel.py b/horizon/test/unit/management/commands/test_startpanel.py index eb4d08be69..7c95414c1a 100644 --- a/horizon/test/unit/management/commands/test_startpanel.py +++ b/horizon/test/unit/management/commands/test_startpanel.py @@ -14,6 +14,7 @@ import mock +import django from django.core.management import call_command from django.core.management import CommandError from django.test import TestCase @@ -29,8 +30,17 @@ class CommandsTestCase(TestCase): def test_startpanel_usage_correct(self, handle): call_command('startpanel', 'test_dash', '--dashboard=foo.bar') - handle.assert_called_with(panel_name='test_dash', dashboard='foo.bar', - extensions=["py", "tmpl", "html"], - files=[], no_color=False, pythonpath=None, - settings=None, skip_checks=True, target=None, - template=None, traceback=False, verbosity=1) + if django.VERSION >= (2, 2): + handle.assert_called_with( + panel_name='test_dash', dashboard='foo.bar', + extensions=["py", "tmpl", "html"], + files=[], force_color=False, no_color=False, pythonpath=None, + settings=None, skip_checks=True, target=None, + template=None, traceback=False, verbosity=1) + else: + handle.assert_called_with( + panel_name='test_dash', dashboard='foo.bar', + extensions=["py", "tmpl", "html"], + files=[], no_color=False, pythonpath=None, + settings=None, skip_checks=True, target=None, + template=None, traceback=False, verbosity=1)