Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle SystemExit also when calling _run_pytest_collect #60

Merged
merged 1 commit into from
May 13, 2016

Commits on May 12, 2016

  1. Handle SystemExit also when calling _run_pytest_collect

    This might happen for e.g. `ptw -- --vv`, where `--vv` is an invalid
    option for `py.test`.
    
    ```
    [0]   …/pyenv/project/bin/ptw(9)<module>()
    -> load_entry_point('pytest-watch', 'console_scripts', 'ptw')()
    [1]   …/pytest-watch/pytest_watch/command.py(85)main()
    -> if not merge_config(args, pytest_args, verbose=args['--verbose']):
    [2]   …/pytest-watch/pytest_watch/config.py(86)merge_config()
    -> config_path = _collect_config(pytest_args, silent)
    [3]   …/pytest-watch/pytest_watch/config.py(68)_collect_config()
    -> return _run_pytest_collect(pytest_args)
    [4]   …/pytest-watch/pytest_watch/config.py(52)_run_pytest_collect()
    -> exit_code = pytest.main(argv, plugins=[collect_config_plugin])
    …
    [20]   …/pyenv/project/lib/python3.5/site-packages/_pytest/config.py(726)parse_args()
    -> self.error('\n'.join(lines))
    [21] > /usr/lib64/python3.5/argparse.py(2385)error()
    -> self.exit(2, _('%(prog)s: error: %(message)s\n') % args)
    [22]   /usr/lib64/python3.5/argparse.py(2372)exit()
    -> _sys.exit(status)
    ```
    
    Now it will look like this, which is still a bit confusing, since it
    refers to `ptw` and not `py.test`:
    
    > Error: Could not run --collect-only to find the pytest config file. Trying again without silencing stdout...
    > usage: ptw [options] [file_or_dir] [file_or_dir] [...]
    > ptw: error: unrecognized arguments: --vv
    >   inifile: …/project/setup.cfg
    >   rootdir: …/project/project
    blueyed committed May 12, 2016
    Configuration menu
    Copy the full SHA
    8e4cf08 View commit details
    Browse the repository at this point in the history