diff --git a/pyproject.toml b/pyproject.toml index 35f3ab4..9e00f78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,7 +71,6 @@ preview = true ignore = [ "E501", # Line too long "F405", # X may be undefined, or defined from star imports - "F841", # Local variable `e_info` is assigned to but never used ] [tool.ruff.lint.flake8-type-checking] diff --git a/tests/test_column_comparer.py b/tests/test_column_comparer.py index f30c63a..dc75e5a 100644 --- a/tests/test_column_comparer.py +++ b/tests/test_column_comparer.py @@ -8,7 +8,7 @@ def describe_assert_column_equality(): def it_throws_error_with_data_mismatch(): data = [("jose", "jose"), ("li", "li"), ("luisa", "laura")] df = spark.createDataFrame(data, ["name", "expected_name"]) - with pytest.raises(ColumnsNotEqualError) as e_info: + with pytest.raises(ColumnsNotEqualError): assert_column_equality(df, "name", "expected_name") def it_doesnt_throw_without_mismatch(): @@ -31,17 +31,17 @@ def it_works_with_no_mismatches(): def it_throws_when_difference_is_bigger_than_precision(): data = [(1.5, 1.1), (1.0004, 1.0005), (0.4, 0.45)] df = spark.createDataFrame(data, ["num1", "num2"]) - with pytest.raises(ColumnsNotEqualError) as e_info: + with pytest.raises(ColumnsNotEqualError): assert_approx_column_equality(df, "num1", "num2", 0.1) def it_throws_when_comparing_floats_with_none(): data = [(1.1, 1.1), (2.2, 2.2), (3.3, None)] df = spark.createDataFrame(data, ["num1", "num2"]) - with pytest.raises(ColumnsNotEqualError) as e_info: + with pytest.raises(ColumnsNotEqualError): assert_approx_column_equality(df, "num1", "num2", 0.1) def it_throws_when_comparing_none_with_floats(): data = [(1.1, 1.1), (2.2, 2.2), (None, 3.3)] df = spark.createDataFrame(data, ["num1", "num2"]) - with pytest.raises(ColumnsNotEqualError) as e_info: + with pytest.raises(ColumnsNotEqualError): assert_approx_column_equality(df, "num1", "num2", 0.1) diff --git a/tests/test_dataframe_comparer.py b/tests/test_dataframe_comparer.py index bf3075a..764a15b 100644 --- a/tests/test_dataframe_comparer.py +++ b/tests/test_dataframe_comparer.py @@ -14,7 +14,7 @@ def it_throws_with_schema_mismatches(): df1 = spark.createDataFrame(data1, ["num", "expected_name"]) data2 = [("bob", "jose"), ("li", "li"), ("luisa", "laura")] df2 = spark.createDataFrame(data2, ["name", "expected_name"]) - with pytest.raises(SchemasNotEqualError) as e_info: + with pytest.raises(SchemasNotEqualError): assert_df_equality(df1, df2) def it_can_work_with_different_row_orders(): @@ -51,7 +51,7 @@ def it_throws_with_schema_column_order_mismatch(): df1 = spark.createDataFrame(data1, ["num", "name"]) data2 = [("jose", 1), ("li", 1)] df2 = spark.createDataFrame(data2, ["name", "num"]) - with pytest.raises(SchemasNotEqualError) as e_info: + with pytest.raises(SchemasNotEqualError): assert_df_equality(df1, df2) def it_does_not_throw_on_schema_column_order_mismatch_with_transforms(): @@ -66,7 +66,7 @@ def it_throws_with_schema_mismatch(): df1 = spark.createDataFrame(data1, ["num", "different_name"]) data2 = [("jose", 1), ("li", 2)] df2 = spark.createDataFrame(data2, ["name", "num"]) - with pytest.raises(SchemasNotEqualError) as e_info: + with pytest.raises(SchemasNotEqualError): assert_df_equality(df1, df2, transforms=[lambda df: df.select(sorted(df.columns))]) def it_throws_with_content_mismatches(): @@ -74,7 +74,7 @@ def it_throws_with_content_mismatches(): df1 = spark.createDataFrame(data1, ["name", "expected_name"]) data2 = [("bob", "jose"), ("li", "li"), ("luisa", "laura")] df2 = spark.createDataFrame(data2, ["name", "expected_name"]) - with pytest.raises(DataFramesNotEqualError) as e_info: + with pytest.raises(DataFramesNotEqualError): assert_df_equality(df1, df2) def it_throws_with_length_mismatches(): @@ -82,7 +82,7 @@ def it_throws_with_length_mismatches(): df1 = spark.createDataFrame(data1, ["name", "expected_name"]) data2 = [("jose", "jose"), ("li", "li")] df2 = spark.createDataFrame(data2, ["name", "expected_name"]) - with pytest.raises(DataFramesNotEqualError) as e_info: + with pytest.raises(DataFramesNotEqualError): assert_df_equality(df1, df2) def it_can_consider_nan_values_equal(): @@ -97,7 +97,7 @@ def it_does_not_consider_nan_values_equal_by_default(): df1 = spark.createDataFrame(data1, ["num", "name"]) data2 = [(float("nan"), "jose"), (2.0, "li")] df2 = spark.createDataFrame(data2, ["num", "name"]) - with pytest.raises(DataFramesNotEqualError) as e_info: + with pytest.raises(DataFramesNotEqualError): assert_df_equality(df1, df2, allow_nan_equality=False) def it_can_ignore_metadata(): @@ -126,7 +126,7 @@ def it_catches_mismatched_metadata(): ]) df1 = spark.createDataFrame(rows_data, schema1) df2 = spark.createDataFrame(rows_data, schema2) - with pytest.raises(SchemasNotEqualError) as e_info: + with pytest.raises(SchemasNotEqualError): assert_df_equality(df1, df2) @@ -159,7 +159,7 @@ def it_throws_with_content_mismatch(): df1 = spark.createDataFrame(data1, ["num", "expected_name"]) data2 = [(1.0, "jose"), (1.05, "li"), (1.0, "laura"), (None, "hi")] df2 = spark.createDataFrame(data2, ["num", "expected_name"]) - with pytest.raises(DataFramesNotEqualError) as e_info: + with pytest.raises(DataFramesNotEqualError): assert_approx_df_equality(df1, df2, 0.1) def it_throws_with_with_length_mismatch(): @@ -167,7 +167,7 @@ def it_throws_with_with_length_mismatch(): df1 = spark.createDataFrame(data1, ["num", "expected_name"]) data2 = [(1.0, "jose"), (1.05, "li")] df2 = spark.createDataFrame(data2, ["num", "expected_name"]) - with pytest.raises(DataFramesNotEqualError) as e_info: + with pytest.raises(DataFramesNotEqualError): assert_approx_df_equality(df1, df2, 0.1) def it_does_not_throw_with_no_mismatch(): diff --git a/tests/test_readme_examples.py b/tests/test_readme_examples.py index a3f3ac5..d3f7f6a 100644 --- a/tests/test_readme_examples.py +++ b/tests/test_readme_examples.py @@ -48,7 +48,7 @@ def test_remove_non_word_characters_nice_error(): "clean_name", remove_non_word_characters(F.col("name")) ) # assert_column_equality(df, "clean_name", "expected_name") - with pytest.raises(ColumnsNotEqualError) as e_info: + with pytest.raises(ColumnsNotEqualError): assert_column_equality(df, "clean_name", "expected_name") @@ -78,7 +78,7 @@ def test_remove_non_word_characters_long_error(): ] expected_df = spark.createDataFrame(expected_data, ["name", "clean_name"]) # assert_df_equality(actual_df, expected_df) - with pytest.raises(DataFramesNotEqualError) as e_info: + with pytest.raises(DataFramesNotEqualError): assert_df_equality(actual_df, expected_df) def ignore_row_order(): @@ -141,7 +141,7 @@ def it_prints_underline_message(): ("rick", 66), ] df2 = spark.createDataFrame(data, ["firstname", "age"]) - with pytest.raises(DataFramesNotEqualError) as e_info: + with pytest.raises(DataFramesNotEqualError): assert_df_equality(df1, df2, underline_cells=True) def it_shows_assert_basic_rows_equality(my_formats): @@ -161,7 +161,7 @@ def it_shows_assert_basic_rows_equality(my_formats): ] df2 = spark.createDataFrame(data, ["firstname", "age"]) # assert_basic_rows_equality(df1.collect(), df2.collect(), formats=my_formats) - with pytest.raises(DataFramesNotEqualError) as e_info: + with pytest.raises(DataFramesNotEqualError): assert_basic_rows_equality(df1.collect(), df2.collect(), underline_cells=True) @@ -174,7 +174,7 @@ def test_approx_col_equality_same(): def test_approx_col_equality_different(): data = [(1.1, 1.1), (2.2, 2.15), (3.3, 5.0), (None, None)] df = spark.createDataFrame(data, ["num1", "num2"]) - with pytest.raises(ColumnsNotEqualError) as e_info: + with pytest.raises(ColumnsNotEqualError): assert_approx_column_equality(df, "num1", "num2", 0.1) def test_approx_df_equality_same(): @@ -190,7 +190,7 @@ def test_approx_df_equality_different(): data2 = [(1.1, "a"), (5.0, "b"), (3.3, "z"), (None, None)] df2 = spark.createDataFrame(data2, ["num", "letter"]) # assert_approx_df_equality(df1, df2, 0.1) - with pytest.raises(DataFramesNotEqualError) as e_info: + with pytest.raises(DataFramesNotEqualError): assert_approx_df_equality(df1, df2, 0.1) @@ -200,7 +200,7 @@ def test_schema_mismatch_message(): df1 = spark.createDataFrame(data1, ["num", "letter"]) data2 = [(1, 6), (2, 7), (3, 8), (None, None)] df2 = spark.createDataFrame(data2, ["num", "num2"]) - with pytest.raises(SchemasNotEqualError) as e_info: + with pytest.raises(SchemasNotEqualError): assert_df_equality(df1, df2) @@ -216,5 +216,5 @@ def test_remove_non_word_characters_long_error(my_chispa): ] expected_df = spark.createDataFrame(expected_data, ["name", "clean_name"]) # my_chispa.assert_df_equality(actual_df, expected_df) - with pytest.raises(DataFramesNotEqualError) as e_info: + with pytest.raises(DataFramesNotEqualError): assert_df_equality(actual_df, expected_df) diff --git a/tests/test_rows_comparer.py b/tests/test_rows_comparer.py index a88fdcf..27d2955 100644 --- a/tests/test_rows_comparer.py +++ b/tests/test_rows_comparer.py @@ -11,7 +11,7 @@ def it_throws_with_row_mismatches(): df1 = spark.createDataFrame(data1, ["num", "expected_name"]) data2 = [("bob", "jose"), ("li", "li"), ("luisa", "laura")] df2 = spark.createDataFrame(data2, ["name", "expected_name"]) - with pytest.raises(DataFramesNotEqualError) as e_info: + with pytest.raises(DataFramesNotEqualError): assert_basic_rows_equality(df1.collect(), df2.collect()) def it_throws_when_rows_have_different_lengths(): @@ -19,7 +19,7 @@ def it_throws_when_rows_have_different_lengths(): df1 = spark.createDataFrame(data1, ["num", "expected_name"]) data2 = [(1, "jose"), (2, "li"), (3, "laura")] df2 = spark.createDataFrame(data2, ["name", "expected_name"]) - with pytest.raises(DataFramesNotEqualError) as e_info: + with pytest.raises(DataFramesNotEqualError): assert_basic_rows_equality(df1.collect(), df2.collect()) def it_works_when_rows_are_the_same(): diff --git a/tests/test_schema_comparer.py b/tests/test_schema_comparer.py index ccb2679..fb7b483 100644 --- a/tests/test_schema_comparer.py +++ b/tests/test_schema_comparer.py @@ -31,7 +31,7 @@ def it_throws_when_column_names_differ(): StructField("name", StringType(), True), StructField("age", IntegerType(), True), ]) - with pytest.raises(SchemasNotEqualError) as e_info: + with pytest.raises(SchemasNotEqualError): assert_schema_equality(s1, s2) def it_throws_when_schema_lengths_differ(): @@ -44,7 +44,7 @@ def it_throws_when_schema_lengths_differ(): StructField("age", IntegerType(), True), StructField("fav_number", IntegerType(), True), ]) - with pytest.raises(SchemasNotEqualError) as e_info: + with pytest.raises(SchemasNotEqualError): assert_schema_equality(s1, s2) @@ -60,7 +60,7 @@ def it_has_good_error_messages_for_different_sized_schemas(): StructField("something", IntegerType(), True), StructField("else", IntegerType(), True), ]) - with pytest.raises(SchemasNotEqualError) as e_info: + with pytest.raises(SchemasNotEqualError): assert_schema_equality_ignore_nullable(s1, s2) def it_does_nothing_when_equal():