Skip to content

Commit

Permalink
Saves the --no-color flag as no_color arg, instead of use_color.
Browse files Browse the repository at this point in the history
I made a bad decision using a "store_false" option. Django itself uses a
"store_true" option and, as we rely on it for version above 1.7, we must
replicate the logic.
  • Loading branch information
michelts committed Jul 17, 2015
1 parent 4116f7f commit 8bd33f0
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 67 deletions.
8 changes: 4 additions & 4 deletions lettuce/__init__.py
Expand Up @@ -90,7 +90,7 @@ class Runner(object):
features and step definitions on there.
"""
def __init__(self, base_path, scenarios=None,
verbosity=0, use_color=True, random=False,
verbosity=0, no_color=False, random=False,
enable_xunit=False, xunit_filename=None,
enable_subunit=False, subunit_filename=None,
tags=None, failfast=False, auto_pdb=False,
Expand Down Expand Up @@ -130,10 +130,10 @@ def __init__(self, base_path, scenarios=None,
' with --no-color flag instead of verbosity 4')
warnings.warn(msg, DeprecationWarning)
elif verbosity is 3:
if use_color:
from lettuce.plugins import colored_shell_output as output
else:
if no_color:
from lettuce.plugins import shell_output as output
else:
from lettuce.plugins import colored_shell_output as output

self.random = random

Expand Down
8 changes: 4 additions & 4 deletions lettuce/bin.py
Expand Up @@ -34,10 +34,10 @@ def main(args=sys.argv[1:]):
help='The verbosity level')

parser.add_option("--no-color",
action="store_false",
dest="use_color",
default=True,
help='Prevent the output to be colored.')
action="store_true",
dest="no_color",
default=False,
help="Don't colorize the command output.")

parser.add_option("-s", "--scenarios",
dest="scenarios",
Expand Down
12 changes: 6 additions & 6 deletions lettuce/django/management/commands/harvest.py
Expand Up @@ -120,10 +120,10 @@ def create_parser(self, prog_name, subcommand):
# Django 1.7 introduces the --no-color flag. We must add the flag
# to be compatible with older django versions
parser.add_option('--no-color',
action='store_false',
dest='use_color',
default=True,
help='Prevent the output to be colored.')
action='store_true',
dest='no_color',
default=False,
help="Don't colorize the command output.")
return parser

def stopserver(self, failed=False):
Expand All @@ -146,7 +146,7 @@ def handle(self, *args, **options):
setup_test_environment()

verbosity = int(options.get('verbosity', 3))
use_color = int(options.get('use_color', True))
no_color = int(options.get('no_color', False))
apps_to_run = tuple(options.get('apps', '').split(","))
apps_to_avoid = tuple(options.get('avoid_apps', '').split(","))
run_server = not options.get('no_server', False)
Expand Down Expand Up @@ -204,7 +204,7 @@ def handle(self, *args, **options):
registry.call_hook('before_each', 'app', app_module)

runner = Runner(path, options.get('scenarios'),
verbosity, use_color,
verbosity, no_color,
enable_xunit=options.get('enable_xunit'),
enable_subunit=options.get('enable_subunit'),
xunit_filename=options.get('xunit_file'),
Expand Down
10 changes: 5 additions & 5 deletions tests/functional/language_specific_features/test_fr.py
Expand Up @@ -28,7 +28,7 @@
def test_output_with_success_colorless():
"Language: fr -> sucess colorless"

runner = Runner(join_path('fr', 'success', 'dumb.feature'), verbosity=3, use_color=False)
runner = Runner(join_path('fr', 'success', 'dumb.feature'), verbosity=3, no_color=True)
runner.run()

assert_stdout_lines(
Expand All @@ -49,7 +49,7 @@ def test_output_with_success_colorless():
def test_output_of_table_with_success_colorless():
"Language: fr -> sucess table colorless"

runner = Runner(join_path('fr', 'success', 'table.feature'), verbosity=3, use_color=False)
runner = Runner(join_path('fr', 'success', 'table.feature'), verbosity=3, no_color=True)
runner.run()

assert_stdout_lines(
Expand All @@ -75,7 +75,7 @@ def test_output_of_table_with_success_colorless():
def test_output_outlines_success_colorless():
"Language: fr -> sucess outlines colorless"

runner = Runner(join_path('fr', 'success', 'outlines.feature'), verbosity=3, use_color=False)
runner = Runner(join_path('fr', 'success', 'outlines.feature'), verbosity=3, no_color=True)
runner.run()

assert_stdout_lines(
Expand Down Expand Up @@ -105,7 +105,7 @@ def test_output_outlines_success_colorless():
def test_output_outlines_success_colorful():
"Language: fr -> sucess outlines colorful"

runner = Runner(join_path('fr', 'success', 'outlines.feature'), verbosity=3, use_color=True)
runner = Runner(join_path('fr', 'success', 'outlines.feature'), verbosity=3, no_color=False)
runner.run()

assert_stdout_lines(
Expand Down Expand Up @@ -134,7 +134,7 @@ def test_output_outlines_success_colorful():
def test_output_outlines2_success_colorful():
"Language: fr -> sucess outlines colorful, alternate name"

runner = Runner(join_path('fr', 'success', 'outlines2.feature'), verbosity=3, use_color=True)
runner = Runner(join_path('fr', 'success', 'outlines2.feature'), verbosity=3, no_color=False)
runner.run()

assert_stdout_lines(
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/language_specific_features/test_ja.py
Expand Up @@ -28,7 +28,7 @@
def test_output_with_success_colorless():
"Language: ja -> sucess colorless"

runner = Runner(join_path('ja', 'success', 'dumb.feature'), verbosity=3, use_color=False)
runner = Runner(join_path('ja', 'success', 'dumb.feature'), verbosity=3, no_color=True)
runner.run()

assert_stdout_lines(
Expand All @@ -48,7 +48,7 @@ def test_output_with_success_colorless():
def test_output_of_table_with_success_colorless():
"Language: ja -> sucess table colorless"

runner = Runner(join_path('ja', 'success', 'table.feature'), verbosity=3, use_color=False)
runner = Runner(join_path('ja', 'success', 'table.feature'), verbosity=3, no_color=True)
runner.run()

assert_stdout_lines(
Expand All @@ -71,7 +71,7 @@ def test_output_of_table_with_success_colorless():
def test_output_outlines_success_colorless():
"Language: ja -> sucess outlines colorless"

runner = Runner(join_path('ja', 'success', 'outlines.feature'), verbosity=3, use_color=False)
runner = Runner(join_path('ja', 'success', 'outlines.feature'), verbosity=3, no_color=True)
runner.run()

assert_stdout_lines(
Expand Down Expand Up @@ -99,7 +99,7 @@ def test_output_outlines_success_colorless():
def test_output_outlines_success_colorful():
"Language: ja -> sucess outlines colorful"

runner = Runner(join_path('ja', 'success', 'outlines.feature'), verbosity=3, use_color=True)
runner = Runner(join_path('ja', 'success', 'outlines.feature'), verbosity=3, no_color=False)
runner.run()

assert_stdout_lines(
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/language_specific_features/test_ptbr.py
Expand Up @@ -28,7 +28,7 @@
def test_output_with_success_colorless():
"Language: pt-br -> sucess colorless"

runner = Runner(join_path('pt-br', 'success', 'dumb.feature'), verbosity=3, use_color=False)
runner = Runner(join_path('pt-br', 'success', 'dumb.feature'), verbosity=3, no_color=True)
runner.run()

assert_stdout_lines(
Expand All @@ -50,7 +50,7 @@ def test_output_with_success_colorless():
def test_output_of_table_with_success_colorless():
"Language: pt-br -> sucess table colorless"

runner = Runner(join_path('pt-br', 'success', 'table.feature'), verbosity=3, use_color=False)
runner = Runner(join_path('pt-br', 'success', 'table.feature'), verbosity=3, no_color=True)
runner.run()

assert_stdout_lines(
Expand All @@ -75,7 +75,7 @@ def test_output_of_table_with_success_colorless():
def test_output_outlines_success_colorless():
"Language: pt-br -> sucess outlines colorless"

runner = Runner(join_path('pt-br', 'success', 'outlines.feature'), verbosity=3, use_color=False)
runner = Runner(join_path('pt-br', 'success', 'outlines.feature'), verbosity=3, no_color=True)
runner.run()

assert_stdout_lines(
Expand Down Expand Up @@ -105,7 +105,7 @@ def test_output_outlines_success_colorless():
def test_output_outlines_success_colorful():
"Language: pt-br -> sucess outlines colorful"

runner = Runner(join_path('pt-br', 'success', 'outlines.feature'), verbosity=3, use_color=True)
runner = Runner(join_path('pt-br', 'success', 'outlines.feature'), verbosity=3, no_color=False)
runner.run()

assert_stdout_lines(
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/language_specific_features/test_ru.py
Expand Up @@ -28,7 +28,7 @@
def test_output_with_success_colorless():
"Language: ru -> sucess colorless"

runner = Runner(join_path('ru', 'success', 'dumb.feature'), verbosity=3, use_color=False)
runner = Runner(join_path('ru', 'success', 'dumb.feature'), verbosity=3, no_color=True)
runner.run()

assert_stdout_lines(
Expand All @@ -51,7 +51,7 @@ def test_output_with_success_colorless():
def test_output_of_table_with_success_colorless():
"Language: ru -> sucess table colorless"

runner = Runner(join_path('ru', 'success', 'table.feature'), verbosity=3, use_color=False)
runner = Runner(join_path('ru', 'success', 'table.feature'), verbosity=3, no_color=True)
runner.run()

assert_stdout_lines(
Expand All @@ -76,7 +76,7 @@ def test_output_of_table_with_success_colorless():
def test_output_outlines_success_colorless():
"Language: ru -> sucess outlines colorless"

runner = Runner(join_path('ru', 'success', 'outlines.feature'), verbosity=3, use_color=False)
runner = Runner(join_path('ru', 'success', 'outlines.feature'), verbosity=3, no_color=True)
runner.run()

assert_stdout_lines(
Expand Down Expand Up @@ -108,7 +108,7 @@ def test_output_outlines_success_colorless():
def test_output_outlines_success_colorful():
"Language: ru -> sucess outlines colorful"

runner = Runner(join_path('ru', 'success', 'outlines.feature'), verbosity=3, use_color=True)
runner = Runner(join_path('ru', 'success', 'outlines.feature'), verbosity=3, no_color=False)
runner.run()

assert_stdout_lines(
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/language_specific_features/test_zh-CN.py
Expand Up @@ -28,7 +28,7 @@
def test_output_with_success_colorless():
"Language: zh-CN -> sucess colorless"

runner = Runner(join_path('zh-CN', 'success', 'dumb.feature'), verbosity=3, use_color=False)
runner = Runner(join_path('zh-CN', 'success', 'dumb.feature'), verbosity=3, no_color=True)
runner.run()

assert_stdout_lines(
Expand All @@ -48,7 +48,7 @@ def test_output_with_success_colorless():
def test_output_of_table_with_success_colorless():
"Language: zh-CN -> sucess table colorless"

runner = Runner(join_path('zh-CN', 'success', 'table.feature'), verbosity=3, use_color=False)
runner = Runner(join_path('zh-CN', 'success', 'table.feature'), verbosity=3, no_color=True)
runner.run()

assert_stdout_lines(
Expand All @@ -71,7 +71,7 @@ def test_output_of_table_with_success_colorless():
def test_output_outlines_success_colorless():
"Language: zh-CN -> sucess outlines colorless"

runner = Runner(join_path('zh-CN', 'success', 'outlines.feature'), verbosity=3, use_color=False)
runner = Runner(join_path('zh-CN', 'success', 'outlines.feature'), verbosity=3, no_color=True)
runner.run()

assert_stdout_lines(
Expand Down Expand Up @@ -99,7 +99,7 @@ def test_output_outlines_success_colorless():
def test_output_outlines_success_colorful():
"Language: zh-CN -> sucess outlines colorful"

runner = Runner(join_path('zh-CN', 'success', 'outlines.feature'), verbosity=3, use_color=True)
runner = Runner(join_path('zh-CN', 'success', 'outlines.feature'), verbosity=3, no_color=False)
runner.run()

assert_stdout_lines(
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/language_specific_features/test_zh-TW.py
Expand Up @@ -28,7 +28,7 @@
def test_output_with_success_colorless():
"Language: zh-TW -> sucess colorless"

runner = Runner(join_path('zh-TW', 'success', 'dumb.feature'), verbosity=3, use_color=False)
runner = Runner(join_path('zh-TW', 'success', 'dumb.feature'), verbosity=3, no_color=True)
runner.run()

assert_stdout_lines(
Expand All @@ -48,7 +48,7 @@ def test_output_with_success_colorless():
def test_output_of_table_with_success_colorless():
"Language: zh-TW -> sucess table colorless"

runner = Runner(join_path('zh-TW', 'success', 'table.feature'), verbosity=3, use_color=False)
runner = Runner(join_path('zh-TW', 'success', 'table.feature'), verbosity=3, no_color=True)
runner.run()

assert_stdout_lines(
Expand All @@ -71,7 +71,7 @@ def test_output_of_table_with_success_colorless():
def test_output_outlines_success_colorless():
"Language: zh-TW -> sucess outlines colorless"

runner = Runner(join_path('zh-TW', 'success', 'outlines.feature'), verbosity=3, use_color=False)
runner = Runner(join_path('zh-TW', 'success', 'outlines.feature'), verbosity=3, no_color=True)
runner.run()

assert_stdout_lines(
Expand Down Expand Up @@ -99,7 +99,7 @@ def test_output_outlines_success_colorless():
def test_output_outlines_success_colorful():
"Language: zh-TW -> sucess outlines colorful"

runner = Runner(join_path('zh-TW', 'success', 'outlines.feature'), verbosity=3, use_color=True)
runner = Runner(join_path('zh-TW', 'success', 'outlines.feature'), verbosity=3, no_color=False)
runner.run()

assert_stdout_lines(
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/test_behave_as_handling.py
Expand Up @@ -37,7 +37,7 @@ def path_to_feature(name):
@with_setup(prepare_stdout)
def test_simple_behave_as_feature():
"Basic step.behave_as behaviour is working"
Runner(path_to_feature('1st_normal_steps'), verbosity=3, use_color=False).run()
Runner(path_to_feature('1st_normal_steps'), verbosity=3, no_color=True).run()
assert_stdout_lines(
"\n"
"Feature: Multiplication # tests/functional/behave_as_features/1st_normal_steps/1st_normal_steps.feature:2\n"
Expand All @@ -62,7 +62,7 @@ def test_simple_behave_as_feature():
@with_setup(prepare_stdout)
def test_simple_tables_behave_as_feature():
"Basic step.behave_as behaviour is working"
Runner(path_to_feature('2nd_table_steps'), verbosity=3, use_color=False).run()
Runner(path_to_feature('2nd_table_steps'), verbosity=3, no_color=True).run()
assert_stdout_lines(
"\n"
"Feature: Multiplication # tests/functional/behave_as_features/2nd_table_steps/2nd_table_steps.feature:2\n"
Expand All @@ -88,7 +88,7 @@ def test_simple_tables_behave_as_feature():
@with_setup(prepare_stdout)
def test_failing_tables_behave_as_feature():
"Basic step.behave_as behaviour is working"
Runner(path_to_feature('3rd_failing_steps'), verbosity=3, use_color=False).run()
Runner(path_to_feature('3rd_failing_steps'), verbosity=3, no_color=True).run()
assert_stdout_lines_with_traceback(
'\n'
'Feature: Multiplication # tests/functional/behave_as_features/3rd_failing_steps/3rd_failing_steps.feature:2\n'
Expand Down

0 comments on commit 8bd33f0

Please sign in to comment.