From 5d12bf636fe9fe5858f59f2012d3bf1ac63138cb Mon Sep 17 00:00:00 2001 From: Tyson Clugg Date: Thu, 7 Jul 2016 23:56:58 +1000 Subject: [PATCH] Make `--ignore-python` the default for invocation as `aloe`, not `nosetests`. --- README.md | 10 ++++------ aloe/__init__.py | 16 ---------------- aloe/__main__.py | 40 ++++++++++++++++++++++++++++++++++++++++ aloe/plugin.py | 27 ++++++++++++++++++--------- setup.py | 2 +- 5 files changed, 63 insertions(+), 32 deletions(-) create mode 100755 aloe/__main__.py diff --git a/README.md b/README.md index d68bf5eb..00c11c4e 100644 --- a/README.md +++ b/README.md @@ -17,13 +17,11 @@ Read the [documentation][docs]. Invocation ---------- -Pass the `--with-gherkin` argument to `nosetests` to run your BDD tests. You -may also pass the `--no-ignore-python` argument to run other nose discovered -tests as well. +Pass the `--with-gherkin` argument to `nosetests` to run your BDD tests. -The `aloe` command line tool is a wrapper for the `nose` runner, configured to -only run Gherkin tests. As such, the invocation is the same as `nose`, but the -following parameters are added: +The `aloe` command line tool is a deprecated wrapper for the `nose` runner, +configured to only run Gherkin tests. As such, the invocation is the same as +`nose`, but the following parameters are added: * `-n N[,N...]` - only run the specified scenarios (by number, 1-based) in each feature. Makes sense when only specifying one feature to run, for example diff --git a/aloe/__init__.py b/aloe/__init__.py index cbf3a8a6..47361589 100755 --- a/aloe/__init__.py +++ b/aloe/__init__.py @@ -9,7 +9,6 @@ from __future__ import division from __future__ import absolute_import -import sys import threading from aloe.registry import ( @@ -20,18 +19,3 @@ ) world = threading.local() # pylint:disable=invalid-name - - -def main(argv=None): # pragma: no cover - """ - Entry point for running Aloe. - """ - - if argv is None: - argv = sys.argv - - from aloe.runner import Runner - Runner(argv) - -if __name__ == '__main__': # pragma: no cover - main() diff --git a/aloe/__main__.py b/aloe/__main__.py new file mode 100755 index 00000000..cdf6db57 --- /dev/null +++ b/aloe/__main__.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +Main module. +""" + +from __future__ import unicode_literals +from __future__ import print_function +from __future__ import division +from __future__ import absolute_import + +import sys +import time + + +def main(argv=None): # pragma: no cover + """ + Entry point for running Aloe. + """ + + import aloe.plugin + aloe.plugin.USING_DEPRECATED_RUNNER = True + sys.stderr.write( + '**************************************************\n' + '* The `aloe` command is deprecated. *\n' + '* Run `nosetests --with-gherkin` instead. *\n' + '* ...sleeping for 3 seconds... *\n' + '**************************************************\n' + ) + time.sleep(3) + + if argv is None: + argv = sys.argv + + from aloe.runner import Runner + Runner(argv) +main.USING_DEPRECATED_RUNNER = False + +if __name__ == '__main__': # pragma: no cover + main() diff --git a/aloe/plugin.py b/aloe/plugin.py index efd39b08..e0b50fab 100644 --- a/aloe/plugin.py +++ b/aloe/plugin.py @@ -24,6 +24,9 @@ from aloe.result import AloeTestResult +USING_DEPRECATED_RUNNER = False + + class GherkinPlugin(Plugin): """ Collect Gherkin tests. @@ -75,29 +78,35 @@ def options(self, parser, env=None): test_class_name = \ '{c.__module__}.{c.__name__}'.format(c=self.TEST_CLASS) + + # default values for command line arguments + parser.set_defaults( + test_class_name=env.get('NOSE_GHERKIN_CLASS', test_class_name), + ignore_python=USING_DEPRECATED_RUNNER, + scenario_indices='', + force_color=False, + ) + parser.add_option( '--test-class', action='store', dest='test_class_name', - default=env.get('NOSE_GHERKIN_CLASS', test_class_name), metavar='TEST_CLASS', help='Base class to use for the generated tests', ) - parser.add_option( - '--no-ignore-python', action='store_false', - dest='ignore_python', - default=True, - help='Run Python and Gherkin tests together', - ) + if USING_DEPRECATED_RUNNER: + parser.add_option( + '--no-ignore-python', action='store_false', + dest='ignore_python', + help='Run Python and Gherkin tests together', + ) parser.add_option( '-n', '--scenario-indices', action='store', dest='scenario_indices', - default='', help='Only run scenarios with these indices (comma-separated)', ) parser.add_option( '--color', action='store_true', dest='force_color', - default=False, help='Force colored output', ) diff --git a/setup.py b/setup.py index 5b7b8552..8bbcad65 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ 'aloe = aloe.plugin:GherkinPlugin', ], 'console_scripts': [ - 'aloe = aloe:main', + 'aloe = aloe.__main__:main', ], },