@@ -1920,24 +1920,14 @@ def test_show_dataframe_spark(session):
19201920 df = session .create_dataframe ([data ], schema = schema )
19211921 spark_col_names = [f"col_{ i + 1 } " for i in range (len (data ))]
19221922
1923- def compare_show_string (actual : str , expected : str ) -> bool :
1923+ def assert_show_string_equals (actual : str , expected : str ):
19241924 actual_lines = actual .strip ().split ("\n " )
19251925 expected_lines = expected .strip ().split ("\n " )
1926- result = [
1927- a .strip () == e .strip () for a , e in zip (actual_lines , expected_lines )
1928- ]
1929- return all (result )
1926+ for a , e in zip (actual_lines , expected_lines ):
1927+ if a .strip () != e .strip ():
1928+ print (f"\n actual:\n { actual } \n expected:{ expected } " )
19301929
1931- print ("\n " )
1932- print (
1933- df ._show_string_spark (
1934- truncate = False ,
1935- _emit_ast = session .ast_enabled ,
1936- _spark_column_names = spark_col_names ,
1937- ).strip ()
1938- )
1939- print ("\n " )
1940- assert compare_show_string (
1930+ assert_show_string_equals (
19411931 df ._show_string_spark (_emit_ast = session .ast_enabled ).strip (),
19421932 dedent (
19431933 """
@@ -1949,7 +1939,7 @@ def compare_show_string(actual: str, expected: str) -> bool:
19491939 """
19501940 ),
19511941 )
1952- assert compare_show_string (
1942+ assert_show_string_equals (
19531943 df ._show_string_spark (
19541944 _emit_ast = session .ast_enabled , _spark_column_names = spark_col_names
19551945 ),
@@ -1963,7 +1953,7 @@ def compare_show_string(actual: str, expected: str) -> bool:
19631953 """
19641954 ),
19651955 )
1966- assert compare_show_string (
1956+ assert_show_string_equals (
19671957 df ._show_string_spark (
19681958 vertical = True ,
19691959 _emit_ast = session .ast_enabled ,
@@ -1988,7 +1978,7 @@ def compare_show_string(actual: str, expected: str) -> bool:
19881978 """
19891979 ),
19901980 )
1991- assert compare_show_string (
1981+ assert_show_string_equals (
19921982 df ._show_string_spark (
19931983 vertical = True ,
19941984 truncate = False ,
@@ -2014,7 +2004,7 @@ def compare_show_string(actual: str, expected: str) -> bool:
20142004 """
20152005 ),
20162006 )
2017- assert compare_show_string (
2007+ assert_show_string_equals (
20182008 df ._show_string_spark (
20192009 truncate = False ,
20202010 _emit_ast = session .ast_enabled ,
@@ -2030,7 +2020,7 @@ def compare_show_string(actual: str, expected: str) -> bool:
20302020 """
20312021 ),
20322022 )
2033- assert compare_show_string (
2023+ assert_show_string_equals (
20342024 df ._show_string_spark (
20352025 truncate = 10 ,
20362026 _emit_ast = session .ast_enabled ,
@@ -2046,6 +2036,7 @@ def compare_show_string(actual: str, expected: str) -> bool:
20462036 """
20472037 ),
20482038 )
2039+ pytest .fail ()
20492040
20502041
20512042@pytest .mark .parametrize ("data" , [[0 , 1 , 2 , 3 ], ["" , "a" ], [False , True ], [None ]])
0 commit comments