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 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_no_color_timestamp(caplog, color): logger.setup_logging(color=color, add_timestamp=True) caplog.clear() with caplog.at_level(logging.DEBUG): logger.logger.info("bar") logger.logger.output("foo") logs = [ rec for rec in caplog.records if rec.levelname in ("INFO", "OUTPUT") ] assert len(logs) == 1 assert hasattr(logs[0], "asctime") caplog.clear() with caplog.at_level(logger.OUTPUT): logger.logger.info("bar") logger.logger.output("foo") logs = [rec for rec in caplog.records if rec.levelname != "OUTPUT"] assert len(logs) == 1 assert hasattr(logs[0], "asctime") logs = [rec for rec in caplog.records if rec.levelname == "OUTPUT"] assert len(logs) == 1 # no timestamp for output assert not hasattr(logs[0], "asctime")
def test_formatter(caplog): caplog.clear() logger.setup_logging(True, verbose=True) with caplog.at_level(logging.DEBUG): logger.logger.info("bar") logger.logger.output("foo") logs = [ rec for rec in caplog.records if rec.levelname in ("INFO", "OUTPUT") ] assert len(logs) == 1 assert not hasattr(logs[0], "asctime") caplog.clear() with caplog.at_level(logger.OUTPUT): logger.logger.info("bar") logger.logger.output("foo") logs = [ rec for rec in caplog.records if rec.levelname in ("INFO", "OUTPUT") ] assert len(logs) == 2 logs = [rec for rec in caplog.records if rec.levelname == "OUTPUT"] assert len(logs) == 1 # Make sure output level log records are not Nox prefixed assert "nox" not in logs[0].message
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( 'posargs', nargs=argparse.REMAINDER, help='Arguments that are passed through to the sessions.') args = parser.parse_args() global_config = GlobalConfig(args) setup_logging() try: success = run(global_config) except KeyboardInterrupt: success = False if not success: sys.exit(1)
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( '-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( 'posargs', nargs=argparse.REMAINDER, help='Arguments that are passed through to the sessions.') args = parser.parse_args() global_config = GlobalConfig(args) setup_logging() try: success = run(global_config) except KeyboardInterrupt: success = False if not success: sys.exit(1)
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)