def test_get_default_user_config_file(self, user_mock, path_mock): def fake_isfile(path): if path == self.home_path: return True else: return False path_mock.side_effect = fake_isfile user_config.get_user_config() user_mock.assert_called_once_with(self.home_path)
def take_action(self, parsed_args): user_conf = user_config.get_user_config(self.app_args.user_config) args = parsed_args if getattr(user_conf, 'last', False): if not user_conf.last.get('no-subunit-trace'): if not args.no_subunit_trace: pretty_out = True else: pretty_out = False else: pretty_out = False pretty_out = args.force_subunit_trace or pretty_out color = args.color or user_conf.last.get('color', False) suppress_attachments = ( args.suppress_attachments or user_conf.last.get( 'suppress-attachments', False)) else: pretty_out = args.force_subunit_trace or not args.no_subunit_trace color = args.color suppress_attachments = args.suppress_attachments return last(repo_type=self.app_args.repo_type, repo_url=self.app_args.repo_url, subunit_out=args.subunit, pretty_out=pretty_out, color=color, suppress_attachments=suppress_attachments)
def take_action(self, parsed_args): user_conf = user_config.get_user_config(self.app_args.user_config) args = parsed_args if getattr(user_conf, 'load', False): force_init = args.force_init or user_conf.load.get( 'force-init', False) pretty_out = args.subunit_trace or user_conf.load.get( 'subunit-trace', False) color = args.color or user_conf.load.get('color', False) abbreviate = args.abbreviate or user_conf.load.get( 'abbreviate', False) suppress_attachments = (args.suppress_attachments or user_conf.load.get( 'suppress-attachments', False)) else: force_init = args.force_init pretty_out = args.subunit_trace color = args.color abbreviate = args.abbreviate suppress_attachments = args.suppress_attachments verbose_level = self.app.options.verbose_level stdout = open(os.devnull, 'w') if verbose_level == 0 else sys.stdout load(repo_type=self.app_args.repo_type, repo_url=self.app_args.repo_url, partial=args.partial, subunit_out=args.subunit, force_init=force_init, streams=args.files, pretty_out=pretty_out, color=color, stdout=stdout, abbreviate=abbreviate, suppress_attachments=suppress_attachments)
def take_action(self, parsed_args): args = parsed_args user_conf = user_config.get_user_config(self.app_args.user_config) show_metadata = args.show_metadata if getattr(user_conf, 'history_list', False): if user_conf.history_show.get('show-metadata', None) is not None: show_metadata = args.show_metadata return history_list(repo_url=self.app_args.repo_url, show_metadata=show_metadata)
def take_action(self, parsed_args): user_conf = user_config.get_user_config(self.app_args.user_config) args = parsed_args if getattr(user_conf, 'failing', False): list_opt = args.list or user_conf.failing.get('list', False) else: list_opt = args.list return failing(repo_url=self.app_args.repo_url, list_tests=list_opt, subunit=args.subunit)
def take_action(self, parsed_args): user_conf = user_config.get_user_config(self.app_args.user_config) args = parsed_args if args.suppress_attachments and args.all_attachments: msg = ("The --suppress-attachments and --all-attachments " "options are mutually exclusive, you can not use both " "at the same time") print(msg) sys.exit(1) if getattr(user_conf, 'load', False): force_init = args.force_init or user_conf.load.get( 'force-init', False) pretty_out = args.subunit_trace or user_conf.load.get( 'subunit-trace', False) color = args.color or user_conf.load.get('color', False) abbreviate = args.abbreviate or user_conf.load.get( 'abbreviate', False) suppress_attachments_conf = user_conf.run.get( 'suppress-attachments', False) all_attachments_conf = user_conf.run.get('all-attachments', False) if not args.suppress_attachments and not args.all_attachments: suppress_attachments = suppress_attachments_conf all_attachments = all_attachments_conf elif args.suppress_attachments: all_attachments = False suppress_attachments = args.suppress_attachments elif args.all_attachments: suppress_attachments = False all_attachments = args.all_attachments else: force_init = args.force_init pretty_out = args.subunit_trace color = args.color abbreviate = args.abbreviate suppress_attachments = args.suppress_attachments all_attachments = args.all_attachments verbose_level = self.app.options.verbose_level stdout = open(os.devnull, 'w') if verbose_level == 0 else sys.stdout load(repo_type=self.app_args.repo_type, repo_url=self.app_args.repo_url, partial=args.partial, subunit_out=args.subunit, force_init=force_init, streams=args.files, pretty_out=pretty_out, color=color, stdout=stdout, abbreviate=abbreviate, suppress_attachments=suppress_attachments, serial=True, all_attachments=all_attachments, show_binary_attachments=args.show_binary_attachments)
def take_action(self, parsed_args): args = parsed_args user_conf = user_config.get_user_config(self.app_args.user_config) if args.suppress_attachments and args.all_attachments: msg = ("The --suppress-attachments and --all-attachments " "options are mutually exclusive, you can not use both " "at the same time") print(msg) sys.exit(1) if getattr(user_conf, 'history_show', False): if not user_conf.history_show.get('no-subunit-trace'): if not args.no_subunit_trace: pretty_out = True else: pretty_out = False else: pretty_out = False pretty_out = args.force_subunit_trace or pretty_out color = args.color or user_conf.history_show.get('color', False) suppress_attachments_conf = user_conf.history_show.get( 'suppress-attachments', False) all_attachments_conf = user_conf.history_show.get( 'all-attachments', False) if not args.suppress_attachments and not args.all_attachments: suppress_attachments = suppress_attachments_conf all_attachments = all_attachments_conf elif args.suppress_attachments: all_attachments = False suppress_attachments = args.suppress_attachments elif args.all_attachments: suppress_attachments = False all_attachments = args.all_attachments else: pretty_out = args.force_subunit_trace or not \ args.no_subunit_trace color = args.color suppress_attachments = args.suppress_attachments all_attachments = args.all_attachments return history_show( args.run_id, repo_url=self.app_args.repo_url, subunit_out=args.subunit, pretty_out=pretty_out, color=color, suppress_attachments=suppress_attachments, all_attachments=all_attachments, show_binary_attachments=args.show_binary_attachments)
def test_get_user_config_invalid_path(self, user_mock, exit_mock): user_config.get_user_config('/i_am_an_invalid_path') msg = 'The specified stestr user config is not a valid path' exit_mock.assert_called_once_with(msg)
def take_action(self, parsed_args): user_conf = user_config.get_user_config(self.app_args.user_config) filters = parsed_args.filters args = parsed_args if getattr(user_conf, 'run', False): if not user_conf.run.get('no-subunit-trace'): if not args.no_subunit_trace: pretty_out = True else: pretty_out = False else: pretty_out = False pretty_out = args.force_subunit_trace or pretty_out if args.concurrency is None: concurrency = user_conf.run.get('concurrency', 0) else: concurrency = args.concurrency random = args.random or user_conf.run.get('random', False) color = args.color or user_conf.run.get('color', False) abbreviate = args.abbreviate or user_conf.run.get( 'abbreviate', False) suppress_attachments = (args.suppress_attachments or user_conf.run.get( 'suppress-attachments', False)) else: pretty_out = args.force_subunit_trace or not args.no_subunit_trace concurrency = args.concurrency or 0 random = args.random color = args.color abbreviate = args.abbreviate suppress_attachments = args.suppress_attachments verbose_level = self.app.options.verbose_level stdout = open(os.devnull, 'w') if verbose_level == 0 else sys.stdout result = run_command(config=self.app_args.config, repo_type=self.app_args.repo_type, repo_url=self.app_args.repo_url, test_path=self.app_args.test_path, top_dir=self.app_args.top_dir, group_regex=self.app_args.group_regex, failing=args.failing, serial=args.serial, concurrency=concurrency, load_list=args.load_list, partial=args.partial, subunit_out=args.subunit, until_failure=args.until_failure, analyze_isolation=args.analyze_isolation, isolated=args.isolated, worker_path=args.worker_path, blacklist_file=args.blacklist_file, whitelist_file=args.whitelist_file, black_regex=args.black_regex, no_discover=args.no_discover, random=random, combine=args.combine, filters=filters, pretty_out=pretty_out, color=color, stdout=stdout, abbreviate=abbreviate, suppress_attachments=suppress_attachments) # Always output slowest test info if requested, regardless of other # test run options user_slowest = False if getattr(user_conf, 'run', False): user_slowest = user_conf.run.get('slowest', False) if args.slowest or user_slowest: slowest.slowest(repo_type=self.app_args.repo_type, repo_url=self.app_args.repo_url) return result
def take_action(self, parsed_args): user_conf = user_config.get_user_config(self.app_args.user_config) filters = parsed_args.filters args = parsed_args if args.suppress_attachments and args.all_attachments: msg = ("The --suppress-attachments and --all-attachments " "options are mutually exclusive, you can not use both " "at the same time") print(msg) sys.exit(1) if getattr(user_conf, 'run', False): if not user_conf.run.get('no-subunit-trace'): if not args.no_subunit_trace: pretty_out = True else: pretty_out = False else: pretty_out = False pretty_out = args.force_subunit_trace or pretty_out if args.concurrency is None: concurrency = user_conf.run.get('concurrency', 0) else: concurrency = args.concurrency random = args.random or user_conf.run.get('random', False) color = args.color or user_conf.run.get('color', False) abbreviate = args.abbreviate or user_conf.run.get( 'abbreviate', False) suppress_attachments_conf = user_conf.run.get( 'suppress-attachments', False) all_attachments_conf = user_conf.run.get( 'all-attachments', False) if not args.suppress_attachments and not args.all_attachments: suppress_attachments = suppress_attachments_conf all_attachments = all_attachments_conf elif args.suppress_attachments: all_attachments = False suppress_attachments = args.suppress_attachments elif args.all_attachments: suppress_attachments = False all_attachments = args.all_attachments else: pretty_out = args.force_subunit_trace or not args.no_subunit_trace concurrency = args.concurrency or 0 random = args.random color = args.color abbreviate = args.abbreviate suppress_attachments = args.suppress_attachments all_attachments = args.all_attachments verbose_level = self.app.options.verbose_level stdout = open(os.devnull, 'w') if verbose_level == 0 else sys.stdout # Make sure all (python) callers have provided an int() concurrency = _to_int(concurrency) if concurrency and concurrency < 0: msg = ("The provided concurrency value: %s is not valid. An " "integer >= 0 must be used.\n" % concurrency) stdout.write(msg) return 2 result = run_command( config=self.app_args.config, repo_type=self.app_args.repo_type, repo_url=self.app_args.repo_url, test_path=self.app_args.test_path, top_dir=self.app_args.top_dir, group_regex=self.app_args.group_regex, failing=args.failing, serial=args.serial, concurrency=concurrency, load_list=args.load_list, partial=args.partial, subunit_out=args.subunit, until_failure=args.until_failure, analyze_isolation=args.analyze_isolation, isolated=args.isolated, worker_path=args.worker_path, blacklist_file=args.blacklist_file, whitelist_file=args.whitelist_file, black_regex=args.black_regex, no_discover=args.no_discover, random=random, combine=args.combine, filters=filters, pretty_out=pretty_out, color=color, stdout=stdout, abbreviate=abbreviate, suppress_attachments=suppress_attachments, all_attachments=all_attachments, show_binary_attachments=args.show_binary_attachments, pdb=args.pdb) # Always output slowest test info if requested, regardless of other # test run options user_slowest = False if getattr(user_conf, 'run', False): user_slowest = user_conf.run.get('slowest', False) if args.slowest or user_slowest: slowest.slowest(repo_type=self.app_args.repo_type, repo_url=self.app_args.repo_url) return result
def test_get_user_config_invalid_path(self, user_mock, exit_mock): user_config.get_user_config('/i_am_an_invalid_path') exit_mock.assert_called_once_with(1)