Skip to content

Commit

Permalink
Add tests for several io utilities (#1697)
Browse files Browse the repository at this point in the history
  • Loading branch information
zundertj committed Nov 8, 2021
1 parent 1b2b0f6 commit ed5a0b0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions py-polars/tests/files/small.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
a,b,c
1,i,16200126
2,j,16250130
3,k,17220012
4,l,17290009
Binary file added py-polars/tests/files/small.parquet
Binary file not shown.
14 changes: 13 additions & 1 deletion py-polars/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io
import pickle
import zlib
from pathlib import Path

import numpy as np
import pandas as pd
Expand All @@ -16,7 +17,8 @@ def test_to_from_buffer(df):
df = df.drop("strings_nulls")

for to_fn, from_fn in zip(
[df.to_parquet, df.to_csv], [pl.read_parquet, pl.read_csv]
[df.to_parquet, df.to_csv, df.to_ipc, df.to_json],
[pl.read_parquet, pl.read_csv, pl.read_ipc, pl.read_json],
):
f = io.BytesIO()
to_fn(f)
Expand Down Expand Up @@ -343,3 +345,13 @@ def test_ignore_parse_dates():
dtypes = {k: pl.Utf8 for k in headers} # Forces Utf8 type for every column
df = pl.read_csv(csv, columns=headers, dtype=dtypes)
assert df.dtypes == [pl.Utf8, pl.Utf8, pl.Utf8]


def test_scan_csv():
df = pl.scan_csv(Path(__file__).parent / "files" / "small.csv")
assert df.collect().shape == (4, 3)


def test_scan_parquet():
df = pl.scan_parquet(Path(__file__).parent / "files" / "small.parquet")
assert df.collect().shape == (4, 3)

0 comments on commit ed5a0b0

Please sign in to comment.