diff options
| author | Tim Graham <timograham@gmail.com> | 2013-07-30 11:30:20 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-07-30 11:30:20 -0400 |
| commit | dffda2ba4e55d4567b3a829d410dae794636ebdd (patch) | |
| tree | 821c021a77ef6dd1d1cc2429fb4ad043fb14eeb6 /tests | |
| parent | 5b47a9c5a0dcb513dc5ff68b617b3aa374c90f3b (diff) | |
Fixed a test that depended on the DB backend; refs #19877. Thanks Loic.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/admin_scripts/management/commands/color_command.py | 9 | ||||
| -rw-r--r-- | tests/admin_scripts/tests.py | 16 |
2 files changed, 15 insertions, 10 deletions
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 0000000000..02da0a14ab --- /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('BEGIN') diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index 68615b787e..e9863ebd94 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -1282,17 +1282,13 @@ 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(), 'BEGIN\n') + + out = StringIO() + call_command('color_command', stdout=out) + self.assertEqual(out.getvalue(), '\x1b[33mBEGIN\x1b[0m\n') def test_base_command(self): "User BaseCommands can execute when a label is provided" |
