Unverified Commit 7a04591c by Michael Youngstrom Committed by GitHub

Merge pull request #5 from edx/youngstrom/fix-args

Add feature argument to the harvest command
parents 31b0dfd8 ce23103f
...@@ -39,7 +39,6 @@ DJANGO_VERSION = StrictVersion(django.get_version()) ...@@ -39,7 +39,6 @@ DJANGO_VERSION = StrictVersion(django.get_version())
class Command(BaseCommand): class Command(BaseCommand):
help = u'Run lettuce tests all along installed apps' help = u'Run lettuce tests all along installed apps'
args = '[PATH to feature file or folder]'
if DJANGO_VERSION < StrictVersion('1.7'): if DJANGO_VERSION < StrictVersion('1.7'):
requires_model_validation = False requires_model_validation = False
...@@ -49,6 +48,10 @@ class Command(BaseCommand): ...@@ -49,6 +48,10 @@ class Command(BaseCommand):
def add_arguments(self, parser): def add_arguments(self, parser):
parser.set_defaults(verbosity=3) # default verbosity is 3 parser.set_defaults(verbosity=3) # default verbosity is 3
parser.add_argument( parser.add_argument(
'features', nargs='*', metavar='feature', action='store',
help='Path to feature file or folder'
)
parser.add_argument(
'-a', '--apps', action='store', dest='apps', default='', '-a', '--apps', action='store', dest='apps', default='',
help='Run ONLY the django apps that are listed here. Comma separated' help='Run ONLY the django apps that are listed here. Comma separated'
) )
...@@ -132,14 +135,14 @@ class Command(BaseCommand): ...@@ -132,14 +135,14 @@ class Command(BaseCommand):
default=False, help="Don't colorize the command output." default=False, help="Don't colorize the command output."
) )
def get_paths(self, args, apps_to_run, apps_to_avoid): def get_paths(self, features, apps_to_run, apps_to_avoid):
if args: if features:
for path, exists in zip(args, map(os.path.exists, args)): for path, exists in zip(features, map(os.path.exists, features)):
if not exists: if not exists:
sys.stderr.write("You passed the path '%s', but it does not exist.\n" % path) sys.stderr.write("You passed the path '%s', but it does not exist.\n" % path)
sys.exit(1) sys.exit(1)
else: else:
paths = args paths = features
else: else:
paths = harvest_lettuces(apps_to_run, apps_to_avoid) # list of tuples with (path, app_module) paths = harvest_lettuces(apps_to_run, apps_to_avoid) # list of tuples with (path, app_module)
...@@ -152,6 +155,7 @@ class Command(BaseCommand): ...@@ -152,6 +155,7 @@ class Command(BaseCommand):
no_color = options.get('no_color', False) no_color = options.get('no_color', False)
apps_to_run = tuple(options['apps'].split(",")) apps_to_run = tuple(options['apps'].split(","))
apps_to_avoid = tuple(options['avoid_apps'].split(",")) apps_to_avoid = tuple(options['avoid_apps'].split(","))
features = options['features']
run_server = not options['no_server'] run_server = not options['no_server']
test_database = options['test_database'] test_database = options['test_database']
smtp_queue = options['smtp_queue'] smtp_queue = options['smtp_queue']
...@@ -183,7 +187,7 @@ class Command(BaseCommand): ...@@ -183,7 +187,7 @@ class Command(BaseCommand):
settings.DEBUG = options.get('debug', False) settings.DEBUG = options.get('debug', False)
paths = self.get_paths(args, apps_to_run, apps_to_avoid) paths = self.get_paths(features, apps_to_run, apps_to_avoid)
server = get_server(port=options['port'], threading=threading) server = get_server(port=options['port'], threading=threading)
if run_server: if run_server:
......
...@@ -1276,7 +1276,7 @@ def test_output_background_with_success_colorless(): ...@@ -1276,7 +1276,7 @@ def test_output_background_with_success_colorless():
' Given the variable "X" holds 2 # tests/functional/test_runner.py:{line}\n' ' Given the variable "X" holds 2 # tests/functional/test_runner.py:{line}\n'
'\n' '\n'
' Scenario: multiplication changing the value # tests/functional/bg_features/simple/simple.feature:9\n' ' Scenario: multiplication changing the value # tests/functional/bg_features/simple/simple.feature:9\n'
' Given the variable "X" is equal to 2 # tests/functional/bg_features/simple/steps.py:5\n' ' Given the variable "X" is equal to 2 # tests/functional/test_runner.py:{line}\n'
'\n' '\n'
'1 feature (1 passed)\n' '1 feature (1 passed)\n'
'1 scenario (1 passed)\n' '1 scenario (1 passed)\n'
...@@ -1314,8 +1314,8 @@ def test_output_background_with_success_colorful(): ...@@ -1314,8 +1314,8 @@ def test_output_background_with_success_colorful():
'\033[A\033[1;32m Given the variable "X" holds 2 \033[1;30m# tests/functional/test_runner.py:{line}\033[0m\n' '\033[A\033[1;32m Given the variable "X" holds 2 \033[1;30m# tests/functional/test_runner.py:{line}\033[0m\n'
'\n' '\n'
'\033[1;37m Scenario: multiplication changing the value \033[1;30m# tests/functional/bg_features/simple/simple.feature:9\033[0m\n' '\033[1;37m Scenario: multiplication changing the value \033[1;30m# tests/functional/bg_features/simple/simple.feature:9\033[0m\n'
'\033[1;30m Given the variable "X" is equal to 2 \033[1;30m# tests/functional/bg_features/simple/steps.py:5\033[0m\n' '\033[1;30m Given the variable "X" is equal to 2 \033[1;30m# tests/functional/test_runner.py:{line}\033[0m\n'
'\033[A\033[1;32m Given the variable "X" is equal to 2 \033[1;30m# tests/functional/bg_features/simple/steps.py:5\033[0m\n' '\033[A\033[1;32m Given the variable "X" is equal to 2 \033[1;30m# tests/functional/test_runner.py:{line}\033[0m\n'
'\n' '\n'
'\033[1;37m1 feature (\033[1;32m1 passed\033[1;37m)\033[0m\n' '\033[1;37m1 feature (\033[1;32m1 passed\033[1;37m)\033[0m\n'
'\033[1;37m1 scenario (\033[1;32m1 passed\033[1;37m)\033[0m\n' '\033[1;37m1 scenario (\033[1;32m1 passed\033[1;37m)\033[0m\n'
...@@ -1446,4 +1446,3 @@ def test_output_with_undefined_steps_colorful(): ...@@ -1446,4 +1446,3 @@ def test_output_with_undefined_steps_colorful():
'def when_this_test_step_is_undefined(step):\n' 'def when_this_test_step_is_undefined(step):\n'
" assert False, 'This step must be implemented'\x1b[0m\n" " assert False, 'This step must be implemented'\x1b[0m\n"
) )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment