def main() -> None: args = _options.options.parse_args() if args.help: _options.options.print_help() return if args.version: print(get_nox_version(), file=sys.stderr) return setup_logging(color=args.color, verbose=args.verbose, add_timestamp=args.add_timestamp) # Execute the appropriate tasks. exit_code = workflow.execute( global_config=args, workflow=( tasks.load_nox_module, tasks.merge_noxfile_options, tasks.discover_manifest, tasks.filter_manifest, tasks.honor_list_request, tasks.run_manifest, tasks.print_summary, tasks.create_report, tasks.final_reduce, ), ) # Done; exit. sys.exit(exit_code)
def test_workflow_interrupted(): # Set up functions for the workflow. function_a = mock.Mock(spec=()) function_b = mock.Mock(spec=()) function_c = mock.Mock(spec=()) # This time, function_b will stop the process by returning an exit # code outright. function_b.side_effect = KeyboardInterrupt # Execute the workflow. exit_code = workflow.execute( workflow=(function_a, function_b, function_c), global_config=mock.sentinel.CONFIG, ) # There were no errors; the final exit code should be 0. assert exit_code == 130 # Each function should have been called with the previous one's # return value. function_a.assert_called_once_with(global_config=mock.sentinel.CONFIG) function_b.assert_called_once_with(function_a.return_value, global_config=mock.sentinel.CONFIG) assert not function_c.called
def main(): args = _options.options.parse_args() if args.help: _options.options.print_help() return if args.version: dist = pkg_resources.get_distribution("nox") print(dist.version, file=sys.stderr) return setup_logging(color=args.color, verbose=args.verbose) # Execute the appropriate tasks. exit_code = workflow.execute( global_config=args, workflow=( tasks.load_nox_module, tasks.merge_noxfile_options, tasks.discover_manifest, tasks.filter_manifest, tasks.honor_list_request, tasks.verify_manifest_nonempty, tasks.run_manifest, tasks.print_summary, tasks.create_report, tasks.final_reduce, ), ) # Done; exit. sys.exit(exit_code)
def test_simple_workflow(): # Set up functions for the workflow. function_a = mock.Mock(spec=()) function_b = mock.Mock(spec=()) function_c = mock.Mock(spec=()) # Execute the workflow. exit_code = workflow.execute( workflow=(function_a, function_b, function_c), global_config=mock.sentinel.CONFIG, ) # There were no errors; the final exit code should be 0. assert exit_code == 0 # Each function should have been called with the previous one's # return value. function_a.assert_called_once_with(global_config=mock.sentinel.CONFIG) function_b.assert_called_once_with( function_a.return_value, global_config=mock.sentinel.CONFIG, ) function_c.assert_called_once_with( function_b.return_value, global_config=mock.sentinel.CONFIG, )
def main(): parser = argparse.ArgumentParser( description='nox is a Python automation toolkit.') parser.add_argument( '-f', '--noxfile', default='nox.py', help='Location of the Python file containing nox sessions.') parser.add_argument('-l', '--list-sessions', action='store_true', help='List all available sessions and exit.') parser.add_argument('--envdir', default='.nox', help='Directory where nox will store virtualenvs.') parser.add_argument( '-s', '-e', '--sessions', nargs='*', help='Which sessions to run, by default, all sessions will run.') parser.add_argument( '-k', '--keywords', help='Only run sessions that match the given expression.') parser.add_argument( '-r', '--reuse-existing-virtualenvs', action='store_true', help='Re-use existing virtualenvs instead of recreating them.') parser.add_argument('--stop-on-first-error', action='store_true', help='Stop after the first error.') parser.add_argument('--report', default=None, help='Output a report of all sessions.') parser.add_argument('--nocolor', default=not sys.stderr.isatty(), action='store_true', help='Disable all color output.') parser.add_argument( '--forcecolor', default=False, action='store_true', help=('Force color output, even if stdout is not an interactive ' 'terminal.')) parser.add_argument( 'posargs', nargs=argparse.REMAINDER, help='Arguments that are passed through to the sessions.') parser.add_argument('--version', action='store_true', help='Output the nox version and exit.') args = parser.parse_args() if args.version: dist = pkg_resources.get_distribution('nox-automation') print(dist.version, file=sys.stderr) return global_config = GlobalConfig(args) setup_logging(color=not args.nocolor or args.forcecolor) # Execute the appropriate tasks. exit_code = workflow.execute( global_config=global_config, workflow=( tasks.load_nox_module, tasks.discover_manifest, tasks.filter_manifest, tasks.honor_list_request, tasks.verify_manifest_nonempty, tasks.run_manifest, tasks.print_summary, tasks.create_report, tasks.final_reduce, ), ) # Done; exit. sys.exit(exit_code)
def main(): parser = argparse.ArgumentParser( description="Nox is a Python automation toolkit.", add_help=False ) primary = parser.add_argument_group( "Primary arguments", "These are the most common arguments used when invoking Nox.", ) primary.add_argument( "-h", "--help", action="store_true", help="Show this help message and exit." ) primary.add_argument( "--version", action="store_true", help="Show the Nox version and exit." ) primary.add_argument( "-l", "--list-sessions", action="store_true", help="List all available sessions and exit.", ) primary.add_argument( "-s", "-e", "--sessions", nargs="*", default=_get_default_sessions(), help="Which sessions to run, by default, all sessions will run.", ) primary.add_argument( "-k", "--keywords", help="Only run sessions that match the given expression." ) primary.add_argument( "posargs", nargs=argparse.REMAINDER, help="Arguments following -- that are passed through to the session(s).", ) secondary = parser.add_argument_group( "Additional arguments & flags", "These arguments are used to control Nox's behavior or control advanced features.", ) secondary.add_argument( "-r", "--reuse-existing-virtualenvs", action="store_true", help="Re-use existing virtualenvs instead of recreating them.", ) secondary.add_argument( "--no-reuse-existing-virtualenvs", action="store_true", help="Disables --reuse-existing-virtualenvs if it is enabled in the Noxfile.", ) secondary.add_argument( "-f", "--noxfile", default="noxfile.py", help="Location of the Python file containing nox sessions.", ) secondary.add_argument( "--envdir", help="Directory where nox will store virtualenvs, this is .nox by default.", ) secondary.add_argument( "-x", "--stop-on-first-error", action="store_true", help="Stop after the first error.", ) secondary.add_argument( "--no-stop-on-first-error", action="store_true", help="Disables --stop-on-first-error if it is enabled in the Noxfile.", ) secondary.add_argument( "--error-on-missing-interpreters", action="store_true", help="Error instead of skip if an interpreter can not be located.", ) secondary.add_argument( "--no-error-on-missing-interpreters", action="store_true", help="Disables --error-on-missing-interpreters if it is enabled in the Noxfile.", ) secondary.add_argument( "--error-on-external-run", action="store_true", help="Error if run() is used to execute a program that isn't installed in a session's virtualenv.", ) secondary.add_argument( "--no-error-on-external-run", action="store_true", help="Disables --error-on-external-run if it is enabled in the Noxfile.", ) secondary.add_argument( "--install-only", action="store_true", help="Skip session.run invocations in the Noxfile.", ) secondary.add_argument( "--report", help="Output a report of all sessions to the given filename." ) secondary.add_argument( "--nocolor", default=not sys.stderr.isatty(), action="store_true", help="Disable all color output.", ) secondary.add_argument( "--forcecolor", default=False, action="store_true", help="Force color output, even if stdout is not an interactive terminal.", ) args = parser.parse_args() if args.help: parser.print_help() return if args.version: dist = pkg_resources.get_distribution("nox") print(dist.version, file=sys.stderr) return global_config = GlobalConfig(args) setup_logging(color=not args.nocolor or args.forcecolor) # Execute the appropriate tasks. exit_code = workflow.execute( global_config=global_config, workflow=( tasks.load_nox_module, tasks.merge_noxfile_options, tasks.discover_manifest, tasks.filter_manifest, tasks.honor_list_request, tasks.verify_manifest_nonempty, tasks.run_manifest, tasks.print_summary, tasks.create_report, tasks.final_reduce, ), ) # Done; exit. sys.exit(exit_code)
def main(): parser = argparse.ArgumentParser( description="Nox is a Python automation toolkit.", add_help=False ) primary = parser.add_argument_group( "Primary arguments", "These are the most common arguments used when invoking Nox.", ) primary.add_argument( "-h", "--help", action="store_true", help="Show this help message and exit." ) primary.add_argument( "--version", action="store_true", help="Show the Nox version and exit." ) primary.add_argument( "-l", "--list-sessions", action="store_true", help="List all available sessions and exit.", ) primary.add_argument( "-s", "-e", "--sessions", nargs="*", default=_get_default_sessions(), help="Which sessions to run, by default, all sessions will run.", ) primary.add_argument( "-k", "--keywords", help="Only run sessions that match the given expression." ) primary.add_argument( "posargs", nargs=argparse.REMAINDER, help="Arguments following -- that are passed through to the session(s).", ) secondary = parser.add_argument_group( "Additional arguments & flags", "These arguments are used to control Nox's behavior or control advanced features.", ) secondary.add_argument( "-r", "--reuse-existing-virtualenvs", action="store_true", help="Re-use existing virtualenvs instead of recreating them.", ) secondary.add_argument( "--no-reuse-existing-virtualenvs", action="store_true", help="Disables --reuse-existing-virtualenvs if it is enabled in the Noxfile.", ) secondary.add_argument( "-f", "--noxfile", default="noxfile.py", help="Location of the Python file containing nox sessions.", ) secondary.add_argument( "--envdir", help="Directory where nox will store virtualenvs, this is .nox by default.", ) secondary.add_argument( "-x", "--stop-on-first-error", action="store_true", help="Stop after the first error.", ) secondary.add_argument( "--no-stop-on-first-error", action="store_true", help="Disables --stop-on-first-error if it is enabled in the Noxfile.", ) secondary.add_argument( "--error-on-missing-interpreters", action="store_true", help="Error instead of skip if an interpreter can not be located.", ) secondary.add_argument( "--no-error-on-missing-interpreters", action="store_true", help="Disables --error-on-missing-interpreters if it is enabled in the Noxfile.", ) secondary.add_argument( "--error-on-external-run", action="store_true", help="Error if run() is used to execute a program that isn't installed in a session's virtualenv.", ) secondary.add_argument( "--no-error-on-external-run", action="store_true", help="Disables --error-on-external-run if it is enabled in the Noxfile.", ) secondary.add_argument( "--install-only", action="store_true", help="Skip session.run invocations in the Noxfile.", ) secondary.add_argument( "--report", help="Output a report of all sessions to the given filename." ) secondary.add_argument( "--nocolor", default="NO_COLOR" in os.environ or not sys.stderr.isatty(), action="store_true", help="Disable all color output.", ) secondary.add_argument( "--forcecolor", default=False, action="store_true", help="Force color output, even if stdout is not an interactive terminal.", ) args = parser.parse_args() if args.help: parser.print_help() return if args.version: dist = pkg_resources.get_distribution("nox") print(dist.version, file=sys.stderr) return global_config = GlobalConfig(args) setup_logging(color=not args.nocolor or args.forcecolor) # Execute the appropriate tasks. exit_code = workflow.execute( global_config=global_config, workflow=( tasks.load_nox_module, tasks.merge_noxfile_options, tasks.discover_manifest, tasks.filter_manifest, tasks.honor_list_request, tasks.verify_manifest_nonempty, tasks.run_manifest, tasks.print_summary, tasks.create_report, tasks.final_reduce, ), ) # Done; exit. sys.exit(exit_code)
def main(): parser = argparse.ArgumentParser(description="nox is a Python automation toolkit.") parser.add_argument( "-f", "--noxfile", default="noxfile.py", help="Location of the Python file containing nox sessions.", ) parser.add_argument( "-l", "--list-sessions", action="store_true", help="List all available sessions and exit.", ) parser.add_argument( "--envdir", default=".nox", help="Directory where nox will store virtualenvs." ) parser.add_argument( "-s", "-e", "--sessions", nargs="*", default=_get_default_sessions(), help="Which sessions to run, by default, all sessions will run.", ) parser.add_argument( "-k", "--keywords", help="Only run sessions that match the given expression." ) parser.add_argument( "-r", "--reuse-existing-virtualenvs", action="store_true", help="Re-use existing virtualenvs instead of recreating them.", ) parser.add_argument( "--stop-on-first-error", action="store_true", help="Stop after the first error." ) parser.add_argument( "--report", default=None, help="Output a report of all sessions." ) parser.add_argument( "--nocolor", default=not sys.stderr.isatty(), action="store_true", help="Disable all color output.", ) parser.add_argument( "--forcecolor", default=False, action="store_true", help=("Force color output, even if stdout is not an interactive " "terminal."), ) parser.add_argument( "posargs", nargs=argparse.REMAINDER, help="Arguments that are passed through to the sessions.", ) parser.add_argument( "--version", action="store_true", help="Output the nox version and exit." ) args = parser.parse_args() if args.version: dist = pkg_resources.get_distribution("nox") print(dist.version, file=sys.stderr) return global_config = GlobalConfig(args) setup_logging(color=not args.nocolor or args.forcecolor) # Execute the appropriate tasks. exit_code = workflow.execute( global_config=global_config, workflow=( tasks.load_nox_module, tasks.discover_manifest, tasks.filter_manifest, tasks.honor_list_request, tasks.verify_manifest_nonempty, tasks.run_manifest, tasks.print_summary, tasks.create_report, tasks.final_reduce, ), ) # Done; exit. sys.exit(exit_code)