From 67dc09d916050f7097f6a0355e505ad205e36b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Falc=C3=A3o?= Date: Sun, 8 Aug 2010 15:36:15 -0300 Subject: [PATCH] improving tests --- test_file_filter.py | 2 +- test_stderr_filter.py | 15 +++++++++++++++ test_stdout_filter.py | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/test_file_filter.py b/test_file_filter.py index 5f4dde9..55c689b 100644 --- a/test_file_filter.py +++ b/test_file_filter.py @@ -89,7 +89,7 @@ def test_minify(): assert_equals("\033[1;32;41mHello\n", couleur.minify("\033[1;32;41mHello\n")) def test_ignoring_colors(): - "file-like filter output: bold green on white" + "file-like filter output: ignoring output" io = StringIO() couleur.proxy(io).enable() diff --git a/test_stderr_filter.py b/test_stderr_filter.py index 86516fa..bd86b56 100644 --- a/test_stderr_filter.py +++ b/test_stderr_filter.py @@ -77,6 +77,21 @@ def test_output_green_and_red_on_white_foreground(): sys.stderr.write("#{black}should not be translated\n") assert_stderr('#{black}should not be translated\n') +@with_setup(prepare_stderr) +def test_errput_stderr_ignoring_errput(): + "STDERR filter errput: ignoring output" + + couleur.proxy(sys.stderr).enable() + couleur.proxy(sys.stderr).ignore() + sys.stderr.write("#{green}Hello #{white}#{on:blue}World!#{reset}\n") + assert_stderr('Hello World!\n') + couleur.proxy(sys.stderr).enable() + sys.stderr.write("#{green}Hi There!\n") + assert_stderr('\033[32mHi There!\n') + couleur.proxy(sys.stderr).disable() + sys.stderr.write("#{black}should not be translated\n") + assert_stderr('#{black}should not be translated\n') + def test_integration_with_stderr(): "STDERR filter integration" diff --git a/test_stdout_filter.py b/test_stdout_filter.py index 0a34f0b..c5d1dd4 100644 --- a/test_stdout_filter.py +++ b/test_stdout_filter.py @@ -77,6 +77,21 @@ def test_output_green_and_red_on_white_foreground(): print "#{black}should not be translated" assert_stdout('#{black}should not be translated\n') +@with_setup(prepare_stdout) +def test_output_stdout_ignoring_output(): + "STDOUT filter output: green foreground and white on red background" + + couleur.proxy(sys.stdout).enable() + couleur.proxy(sys.stdout).ignore() + print "#{green}Hello #{white}#{on:blue}World!#{reset}" + assert_stdout('Hello World!\n') + couleur.proxy(sys.stdout).enable() + print "#{green}Hi There!" + assert_stdout('\033[32mHi There!\n') + couleur.proxy(sys.stdout).disable() + print "#{black}should not be translated" + assert_stdout('#{black}should not be translated\n') + def test_integration_with_stdout(): "STDOUT filter integration"