@@ -297,6 +297,37 @@ def simple_format(x):
297297 return "\n " .join (actualize (l ) for l in x )
298298
299299
300+ def assertFSArraysEqual (a , b ):
301+ # type: (FSArray, FSArray) -> None
302+ assert isinstance (a , FSArray )
303+ assert isinstance (b , FSArray )
304+ assert (
305+ a .width == b .width and a .hight == b .hight
306+ ), f"fsarray dimensions do not match: { a .shape } { b .shape } "
307+ for i , (a_row , b_row ) in enumerate (zip (a , b )):
308+ assert a_row == b_row , "FSArrays differ first on line {}:\n {}" .format (
309+ i , FSArray .diff (a , b )
310+ )
311+
312+
313+ def assertFSArraysEqualIgnoringFormatting (a , b ):
314+ # type: (FSArray, FSArray) -> None
315+ """Also accepts arrays of strings"""
316+ assert len (a ) == len (b ), "fsarray heights do not match: %s %s \n %s \n %s" % (
317+ len (a ),
318+ len (b ),
319+ simple_format (a ),
320+ simple_format (b ),
321+ )
322+ for i , (a_row , b_row ) in enumerate (zip (a , b )):
323+ a_row = a_row .s if isinstance (a_row , FmtStr ) else a_row
324+ b_row = b_row .s if isinstance (b_row , FmtStr ) else b_row
325+ assert a_row == b_row , "FSArrays differ first on line %s:\n %s" % (
326+ i ,
327+ FSArray .diff (a , b , ignore_formatting = True ),
328+ )
329+
330+
300331if __name__ == "__main__" :
301332 a = FSArray (3 , 14 , bg = "blue" )
302333 a [0 :2 , 5 :11 ] = cast (
0 commit comments