Beispiel #1
0
def test_dataframe_handle_cli(capsys, tmpdir):
    def test_func(df):
        return df["name"][0]

    handler = DataframeHandler()

    json_file = tmpdir.join("test.json")
    with open(str(json_file), "w") as f:
        f.write('[{"name": "john","game": "mario","city": "sf"}]')

    test_args = ["--input={}".format(json_file)]
    handler.handle_cli(test_args, test_func)
    out, err = capsys.readouterr()
    assert out.strip().endswith("john")
Beispiel #2
0
def test_dataframe_handle_cli(capsys, tmpdir):
    def test_func(df):
        return df['name'][0]

    handler = DataframeHandler()

    import json
    json_file = tmpdir.join('test.json')
    with open(str(json_file), 'w') as f:
        f.write('[{"name": "john","game": "mario","city": "sf"}]')

    test_args = ['--input={}'.format(json_file)]
    handler.handle_cli(test_args, test_func)
    out, err = capsys.readouterr()
    assert out.strip().endswith('john')