summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorareski <areski@gmail.com>2014-07-29 15:18:44 +0200
committerTim Graham <timograham@gmail.com>2014-07-30 12:59:39 -0400
commit7cb4a82eaf2c6b59a80699ae91b63180eb8a47ef (patch)
treef73ccb091431f4b8dfce10d98e1642e4ac4b6a9c
parent813f938093a2c9a04ec69ff18bdb61413adf61a4 (diff)
[1.7.x] Fixed #23107 -- Made runserver output respect --no-color.
Backport of 67d7da5fb9 from master
-rw-r--r--django/core/management/base.py1
-rw-r--r--tests/admin_scripts/tests.py1
2 files changed, 2 insertions, 0 deletions
diff --git a/django/core/management/base.py b/django/core/management/base.py
index 52f4a074dc..0734324eb7 100644
--- a/django/core/management/base.py
+++ b/django/core/management/base.py
@@ -305,6 +305,7 @@ class BaseCommand(object):
if options.get('no_color'):
self.style = no_style()
self.stderr = OutputWrapper(options.get('stderr', sys.stderr))
+ os.environ["DJANGO_COLORS"] = "nocolor"
else:
self.stderr = OutputWrapper(options.get('stderr', sys.stderr), self.style.ERROR)
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index 00498e122f..da00841cdb 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -1385,6 +1385,7 @@ class CommandTypes(AdminScriptTestCase):
out = StringIO()
call_command('color_command', no_color=True, stdout=out)
+ self.assertEqual(os.environ.get('DJANGO_COLORS', ''), 'nocolor')
self.assertEqual(out.getvalue(), 'BEGIN\n')
def test_base_command(self):