def test_write_existing_conf(tmp, mocker): mocked_input = mocker.patch('mozregression.config.input') mocked_input.return_value = "" conf_path = os.path.join(tmp, 'conf.cfg') write_conf(conf_path) results = get_defaults(conf_path) assert results # write conf again write_conf(conf_path) # nothing changed assert results == get_defaults(conf_path) with open(conf_path) as f: # ensure we have comments assert "# ------ mozregression configuration file ------" in f.read()
def test_write_existing_conf(tmp, mocker): mocked_input = mocker.patch("__builtin__.raw_input") mocked_input.return_value = "" conf_path = os.path.join(tmp, "conf.cfg") write_conf(conf_path) results = get_defaults(conf_path) assert results # write conf again write_conf(conf_path) # nothing changed assert results == get_defaults(conf_path) with open(conf_path) as f: # ensure we have comments assert "# ------ mozregression configuration file ------" in f.read()
def test_write_conf(tmp, mocker, os_, bits, inputs, conf_dir_exists, results): mozinfo = mocker.patch('mozregression.config.mozinfo') mozinfo.os = os_ mozinfo.bits = bits mocked_input = mocker.patch('__builtin__.raw_input') mocked_input.side_effect = inputs conf_path = os.path.join(tmp, 'conf.cfg') if not conf_dir_exists: mozfile.remove(conf_path) write_conf(conf_path) if 'persist' in results and results['persist'] is None: # default persist is base on the directory of the conf file results['persist'] = os.path.join(tmp, 'persist') conf = get_defaults(conf_path) for key in results: assert conf[key] == results[key] with open(conf_path) as f: # ensure we have comments assert "# ------ mozregression configuration file ------" in f.read()
def test_write_conf(tmp, mocker, os_, bits, inputs, conf_dir_exists, results): mozinfo = mocker.patch("mozregression.config.mozinfo") mozinfo.os = os_ mozinfo.bits = bits mocked_input = mocker.patch("__builtin__.raw_input") mocked_input.side_effect = inputs conf_path = os.path.join(tmp, "conf.cfg") if not conf_dir_exists: mozfile.remove(conf_path) write_conf(conf_path) if "persist" in results and results["persist"] is None: # default persist is base on the directory of the conf file results["persist"] = os.path.join(tmp, "persist") conf = get_defaults(conf_path) for key in results: assert conf[key] == results[key] with open(conf_path) as f: # ensure we have comments assert "# ------ mozregression configuration file ------" in f.read()
def __call__(self, parser, namespace, values, option_string=None): write_conf(DEFAULT_CONF_FNAME) parser.exit()