-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import pytest | ||
import pandas as pd | ||
from dictionaries import convert_to_pandas_df # Replace with your actual module name | ||
|
||
|
||
def test_normal_input(): | ||
sample_data = [(1, 2), (3, 4)] | ||
expected_output = pd.DataFrame({"Key": [1, 3], "Value": [2, 4]}) | ||
pd.testing.assert_frame_equal(convert_to_pandas_df(sample_data), expected_output) | ||
|
||
|
||
def test_empty_input(): | ||
sample_data = [] | ||
expected_output = pd.DataFrame(columns=["Key", "Value"]) | ||
pd.testing.assert_frame_equal(convert_to_pandas_df(sample_data), expected_output) | ||
|
||
|
||
def test_multiple_entries(): | ||
sample_data = [("a", 1), ("a", 2), ("a", 3)] | ||
expected_output = pd.DataFrame({"Key": ["a", "a", "a"], "Value": [1, 2, 3]}) | ||
pd.testing.assert_frame_equal(convert_to_pandas_df(sample_data), expected_output) | ||
|
||
|
||
def test_invalid_input_data(): | ||
with pytest.raises(TypeError): | ||
convert_to_pandas_df("invalid data") | ||
|
||
|
||
def test_incorrect_tuple_length(): | ||
sample_data = [("a", 1, "extra"), ("b", 2)] | ||
with pytest.raises(ValueError): | ||
convert_to_pandas_df(sample_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import pytest | ||
import polars as pl | ||
from polars.testing import assert_frame_equal, assert_series_equal | ||
from dictionaries import convert_to_polars_df | ||
|
||
|
||
def test_normal_input(): | ||
sample_data = [(1, 2), (3, 4)] | ||
expected_output = pl.DataFrame( | ||
{"column_0": [1, 2], "column_1": [3, 4]} | ||
) # Corrected expected values | ||
pl.testing.assert_frame_equal(convert_to_polars_df(sample_data), expected_output) | ||
|
||
|
||
def test_empty_input(): | ||
sample_data = [] | ||
expected_output = pl.DataFrame() | ||
pl.testing.assert_frame_equal(convert_to_polars_df(sample_data), expected_output) | ||
|
||
|
||
def test_multiple_entries(): | ||
sample_data = [("a", 1), ("a", 2), ("a", 3)] | ||
expected_output = pl.DataFrame({"column_0": ["a", "a", "a"], "column_1": [1, 2, 3]}) | ||
pl.testing.assert_frame_equal(convert_to_polars_df(sample_data), expected_output) | ||
|
||
|
||
def test_invalid_input_data(): | ||
with pytest.raises(TypeError): | ||
convert_to_polars_df("invalid data") | ||
|
||
|
||
def test_incorrect_tuple_length(): | ||
sample_data = [("a", 1, "extra"), ("b", 2)] | ||
with pytest.raises(ValueError): | ||
convert_to_polars_df(sample_data) |