def test_correctly_coverts_true_string_to_true_type(self): dic = cmd_utils.lines_to_dict(["A True"]) assert dic["A"] is True
def test_correctly_coverts_number_string_to_float_type(self): dic = cmd_utils.lines_to_dict(["A 7"]) assert dic["A"] == 7.
def test_correctly_coverts_none_string_to_none_type(self): dic = cmd_utils.lines_to_dict(["A None"]) assert dic["A"] is None
def test_raises_exception_if_input_is_not_list(self): invalid_lines = "One point twenty-one Jigawatts!" with pytest.raises(ValueError): dic = cmd_utils.lines_to_dict(invalid_lines)
def test_bogus_string_raises_unknown_response(self): invalid_lines = ["One point twenty-one Jigawatts!"] dic = cmd_utils.lines_to_dict(invalid_lines) warnings.warn("Bogus data passes silently through parse_config()") pass
def test_correctly_formatted_string_returns_ordered_dict(self): valid_lines = ["NO_COMMENT True", "WITH_COMMENT foo # bar"] dic = cmd_utils.lines_to_dict(valid_lines) assert dic["NO_COMMENT"] is True assert dic["WITH_COMMENT"] == "foo"
def test_empty_str_returns_empty_dict(self): dic = cmd_utils.lines_to_dict([]) assert len(dic) == 0