MCPcopy Create free account
hub / github.com/apache/arrow / test_parse_options

Function test_parse_options

python/pyarrow/tests/test_json.py:102–134  ·  view source on GitHub ↗
(pickle_module)

Source from the content-addressed store, hash-verified

100
101
102def test_parse_options(pickle_module):
103 cls = ParseOptions
104 opts = cls()
105 assert opts.newlines_in_values is False
106 assert opts.explicit_schema is None
107
108 opts.newlines_in_values = True
109 assert opts.newlines_in_values is True
110
111 expected_repr_inner = """
112 explicit_schema=None,
113 newlines_in_values=True,
114 unexpected_field_behavior='infer'"""
115
116 assert repr(opts) == f"<pyarrow.json.ParseOptions>({expected_repr_inner})"
117 assert str(opts) == f"ParseOptions({expected_repr_inner})"
118
119 schema = pa.schema([pa.field('foo', pa.int32())])
120 opts.explicit_schema = schema
121 assert opts.explicit_schema == schema
122
123 assert opts.unexpected_field_behavior == "infer"
124 for value in ["ignore", "error", "infer"]:
125 opts.unexpected_field_behavior = value
126 assert opts.unexpected_field_behavior == value
127
128 with pytest.raises(ValueError):
129 opts.unexpected_field_behavior = "invalid-value"
130
131 check_options_class_pickling(cls, pickler=pickle_module,
132 explicit_schema=schema,
133 newlines_in_values=False,
134 unexpected_field_behavior="ignore")
135
136
137class BaseTestJSON(abc.ABC):

Callers

nothing calls this directly

Calls 3

schemaMethod · 0.45
fieldMethod · 0.45

Tested by

no test coverage detected