def test_deprecate_wrong_docstring(): msg = "deprecate needs a correctly formatted docstring" with pytest.raises(AssertionError, match=msg): deprecate("depr_func", new_func_wrong_docstring, "1.0", msg="Use new_func instead.")
def test_deprecate_wrong_docstring(): with pytest.raises(AssertionError, match='deprecate needs a correctly ' 'formatted docstring'): deprecate('depr_func', new_func_wrong_docstring, '1.0', msg='Use new_func instead.')
def test_deprecate_no_docstring(): depr_func = deprecate( "depr_func", new_func_no_docstring, "1.0", msg="Use new_func instead." ) with tm.assert_produces_warning(FutureWarning): result = depr_func() assert result == "new_func_no_docstring called"
def test_deprecate_no_docstring(): depr_func = deprecate('depr_func', new_func_no_docstring, '1.0', msg='Use new_func instead.') with tm.assert_produces_warning(FutureWarning): result = depr_func() assert result == 'new_func_no_docstring called'
def test_deprecate_ok(): depr_func = deprecate("depr_func", new_func, "1.0", msg="Use new_func instead.") with tm.assert_produces_warning(FutureWarning): result = depr_func() assert result == "new_func called" assert depr_func.__doc__ == dedent(new_func_with_deprecation.__doc__)
def test_deprecate_ok(): depr_func = deprecate('depr_func', new_func, '1.0', msg='Use new_func instead.') with tm.assert_produces_warning(FutureWarning): result = depr_func() assert result == 'new_func called' assert depr_func.__doc__ == dedent(new_func_with_deprecation.__doc__)
lengths.append(len(recs)) for val, key in zip(_meta, meta_keys): if level + 1 > len(val): meta_val = seen_meta[key] else: meta_val = _pull_field(obj, val[level:]) meta_vals[key].append(meta_val) records.extend(recs) _recursive_extract(data, record_path, {}, level=0) result = DataFrame(records) if record_prefix is not None: result = result.rename(columns=lambda x: f"{record_prefix}{x}") # Data types, a problem for k, v in meta_vals.items(): if meta_prefix is not None: k = meta_prefix + k if k in result: raise ValueError( f"Conflicting metadata name {k}, need distinguishing prefix ") result[k] = np.array(v, dtype=object).repeat(lengths) return result json_normalize = deprecate("pandas.io.json.json_normalize", _json_normalize, "1.0.0", "pandas.json_normalize")