I have a function that looks somewhat like this:
def foo(a):
   print(a**2)
Now I want to test my function. I have a couple of input files and expected output files. The approach I was trying is reading in the variable in the input files and redirect the print to a file and compare that file to the given solution file:
def test_foo():
   with open(path) as f:
      a = int(f.read())
   ### How output print to file and compare it to solution file?
The question is, how would I redirect the print and compare the two files if they are the same?
Philipp
