66import polars as pl
77import pytest
88
9- from diffly import compare_frames
9+ from diffly import PrimaryKeyError , compare_frames
1010
1111
12- @pytest .mark .parametrize ("primary_key" , ["name" , ["name" ], ("name" )])
12+ @pytest .mark .parametrize ("primary_key" , ["name" , ["name" ], ("name" , )])
1313def test_primary_key_sequence_types (primary_key : str | Sequence [str ]) -> None :
1414 left = pl .DataFrame ({"name" : ["a" , "b" ], "value" : [1 , 2 ]})
1515 right = pl .DataFrame ({"name" : ["a" , "b" ], "other" : [3 , 4 ]})
@@ -20,7 +20,7 @@ def test_primary_key_sequence_types(primary_key: str | Sequence[str]) -> None:
2020def test_empty_primary_key () -> None :
2121 left = pl .DataFrame ({"name" : ["a" , "b" ], "value" : [1 , 2 ]})
2222 right = pl .DataFrame ({"name" : ["a" , "b" ], "other" : [3 , 4 ]})
23- with pytest .raises (ValueError , match = "empty" ):
23+ with pytest .raises (PrimaryKeyError , match = "empty" ):
2424 compare_frames (left , right , primary_key = [])
2525
2626
@@ -38,9 +38,9 @@ def test_missing_primary_key() -> None:
3838def test_pk_violation () -> None :
3939 df_valid = pl .DataFrame ({"id" : ["a" , "b" ], "value" : [1 , 2 ]})
4040 df_duplicates = pl .DataFrame ({"id" : ["a" , "a" ], "value" : [1 , 2 ]})
41- with pytest .raises (ValueError , match = "primary key.*left" ):
41+ with pytest .raises (PrimaryKeyError , match = "primary key.*left" ):
4242 compare_frames (df_duplicates , df_valid , primary_key = ["id" ])
43- with pytest .raises (ValueError , match = "primary key.*right" ):
43+ with pytest .raises (PrimaryKeyError , match = "primary key.*right" ):
4444 compare_frames (df_valid , df_duplicates , primary_key = ["id" ])
4545
4646
0 commit comments