diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2013-02-10 11:55:33 +0100 |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2013-02-10 11:55:33 +0100 |
commit | 030ac6e3c7a3cf09209d2bb3afeb560a530f0c06 (patch) | |
tree | 14ba4ae7c7e9ba46184b47722593b735c7e265de | |
parent | 1dbd8903d74a93ed696a0707cb45cce1bd383b44 (diff) | |
download | pep8-030ac6e3c7a3cf09209d2bb3afeb560a530f0c06.tar.gz |
Hide the --doctest and --testsuite options when installed
-rw-r--r-- | CHANGES.txt | 6 | ||||
-rw-r--r-- | docs/intro.rst | 2 | ||||
-rwxr-xr-x | pep8.py | 20 |
3 files changed, 17 insertions, 11 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 916d967..84c92af 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,6 +2,12 @@ Changelog ========= +1.4.x (unreleased) +------------------ + +* Hide the ``--doctest`` and ``--testsuite`` options when installed. + + 1.4.2 (2013-02-10) ------------------ diff --git a/docs/intro.rst b/docs/intro.rst index bb9f980..1456956 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -143,8 +143,6 @@ Quick help is available on the command line:: received on STDIN Testing Options: - --testsuite=dir run regression tests from dir - --doctest run doctest on myself --benchmark measure processing speed Configuration: @@ -45,7 +45,7 @@ W warnings 700 statements 900 syntax error """ -__version__ = '1.4.2' +__version__ = '1.4.3a0' import os import sys @@ -70,6 +70,7 @@ else: DEFAULT_CONFIG = os.path.join(os.getenv('XDG_CONFIG_HOME') or os.path.expanduser('~/.config'), 'pep8') PROJECT_CONFIG = ('.pep8', 'tox.ini', 'setup.cfg') +TESTSUITE_PATH = os.path.join(os.path.dirname(__file__), 'testsuite') MAX_LINE_LENGTH = 79 REPORT_FORMAT = { 'default': '%(path)s:%(row)d:%(col)d: %(code)s %(text)s', @@ -1719,10 +1720,11 @@ def get_parser(prog='pep8', version=__version__): help="report only lines changed according to the " "unified diff received on STDIN") group = parser.add_option_group("Testing Options") - group.add_option('--testsuite', metavar='dir', - help="run regression tests from dir") - group.add_option('--doctest', action='store_true', - help="run doctest on myself") + if os.path.exists(TESTSUITE_PATH): + group.add_option('--testsuite', metavar='dir', + help="run regression tests from dir") + group.add_option('--doctest', action='store_true', + help="run doctest on myself") group.add_option('--benchmark', action='store_true', help="measure processing speed") return parser @@ -1781,7 +1783,7 @@ def read_config(options, args, arglist, parser): # Third, overwrite with the command-line options options, _ = parser.parse_args(arglist, values=new_options) - + options.doctest = options.testsuite = False return options @@ -1806,9 +1808,9 @@ def process_options(arglist=None, parse_argv=False, config_file=None, options, args = parser.parse_args(arglist) options.reporter = None - if options.testsuite: + if options.ensure_value('testsuite', False): args.append(options.testsuite) - elif not options.doctest: + elif not options.ensure_value('doctest', False): if parse_argv and not args: if options.diff or any(os.path.exists(name) for name in PROJECT_CONFIG): @@ -1845,7 +1847,7 @@ def _main(): pep8style = StyleGuide(parse_argv=True, config_file=True) options = pep8style.options if options.doctest or options.testsuite: - sys.path[:0] = [os.path.join(os.path.dirname(__file__), 'testsuite')] + sys.path[:0] = [TESTSUITE_PATH] from test_pep8 import run_tests del sys.path[0] report = run_tests(pep8style, options.doctest, options.testsuite) |