@@ -1603,13 +1603,15 @@ def test_is_str(df_simple):
16031603 with pytest .raises (KeyError ):
16041604 navdata .is_str (0 )
16051605
1606- def test_str_navdata (df_simple ):
1606+ def test_str_navdata (df_simple , df_only_header ):
16071607 """Test that the NavData class can be printed without errors
16081608
16091609 Parameters
16101610 ----------
16111611 df_simple : pd.DataFrame
16121612 Dataframe with which to construct NavData instance
1613+ df_only_header : pd.DataFrame
1614+ Dataframe with only column names and no data
16131615 """
16141616 navdata = NavData (pandas_df = df_simple )
16151617 navdata_str = str (navdata )
@@ -1618,6 +1620,18 @@ def test_str_navdata(df_simple):
16181620 df_str = str (df_simple )
16191621 assert navdata_str == df_str
16201622
1623+ # make sure print doesn't break if given only headers
1624+ navdata_str = str (NavData (pandas_df = df_only_header ))
1625+ df_str = str (df_only_header ).replace ("DataFrame" ,"NavData" )
1626+ df_str = df_str .replace ("Columns" ,"Rows" )
1627+ assert navdata_str == df_str
1628+
1629+ # make sure it doesn't break with empty NavData
1630+ navdata_str = str (NavData ())
1631+ df_str = str (pd .DataFrame ()).replace ("DataFrame" ,"NavData" )
1632+ df_str = df_str .replace ("Columns" ,"Rows" )
1633+ assert navdata_str == df_str
1634+
16211635def test_in_rows_single (data ):
16221636 """Test the in_rows function.
16231637
0 commit comments