python - Asserting a function that prints an array -


this question has answer here:

i trying test function

def print_board(m):     in range (m.shape[0]):         line=''         j in range (m.shape[1]):            line+=str(int(m[i,j]))         print(line) 

i created new file test , imported file , function array not sure on how can test since don't return it, tried :

assert(print_board(array([[1,1,1],[0,0,0],[1,1,1]],dtype='bool')) == '''111 000 111''') 

but got

assertionerror

what redirect python standard output (where print sends it) string, , compare string.

see this question explanation of how that.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -