Skip to content

Instantly share code, notes, and snippets.

@loic
Last active December 20, 2015 10:09
Show Gist options
  • Select an option

  • Save loic/6113942 to your computer and use it in GitHub Desktop.

Select an option

Save loic/6113942 to your computer and use it in GitHub Desktop.
diff --git a/tests/admin_scripts/management/commands/color_command.py b/tests/admin_scripts/management/commands/color_command.py
new file mode 100644
index 0000000..fda93a5
--- /dev/null
+++ b/tests/admin_scripts/management/commands/color_command.py
@@ -0,0 +1,9 @@
+from django.core.management.base import NoArgsCommand
+
+
+class Command(NoArgsCommand):
+ help = "Test color output"
+ requires_model_validation = False
+
+ def handle_noargs(self, **options):
+ return self.style.SQL_KEYWORD('UNIQUE')
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index 68615b7..680bce3 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -1282,17 +1282,8 @@ class CommandTypes(AdminScriptTestCase):
def test_no_color(self):
"--no-color prevent colorization of the output"
out = StringIO()
- call_command("sqlall", "admin_scripts", no_color=True, stdout=out)
- self.assertEqual(out.getvalue(), """BEGIN;
-CREATE TABLE "admin_scripts_article" (
- "id" integer NOT NULL PRIMARY KEY,
- "headline" varchar(100) NOT NULL,
- "pub_date" datetime NOT NULL
-)
-;
-
-COMMIT;
-""")
+ call_command("color_command", no_color=True, stdout=out)
+ self.assertEqual(out.getvalue(), "UNIQUE\n")
def test_base_command(self):
"User BaseCommands can execute when a label is provided"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment