66import polars as pl
77import pytest
88
9- from diffly import compare_frames
9+ from diffly import PrimaryKeyError , compare_frames
1010
1111
1212@pytest .mark .parametrize ("primary_key" , ["name" , ["name" ], ("name" )])
@@ -20,27 +20,27 @@ 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
2727def test_missing_primary_key () -> None :
2828 left = pl .DataFrame ({"name" : ["a" , "b" ], "value" : [1 , 2 ]})
2929 right = pl .DataFrame ({"name" : ["a" , "b" ], "other" : [3 , 4 ]})
3030 # Primary key that neither frame has
31- with pytest .raises (ValueError , match = "left.*missing.*co2_emissions" ):
31+ with pytest .raises (PrimaryKeyError , match = "left.*missing.*co2_emissions" ):
3232 compare_frames (left , right , primary_key = ["co2_emissions" ])
3333 # Primary key that the right frame does not have
34- with pytest .raises (ValueError , match = "right.*missing.*value" ):
34+ with pytest .raises (PrimaryKeyError , match = "right.*missing.*value" ):
3535 compare_frames (left , right , primary_key = ["value" ])
3636
3737
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