How to test Python function which writes to file

Viewed 397

I have a Python function that takes a list as an argument and writes it to a file:

def write_file(a):
    try:
        f = open('testfile', 'w')
        for i in a:
            f.write(str(i))

    finally:
        f.close()

How do I test this function ?

def test_write_file(self):
    a = [1,2,3]
    #what next ?
2 Answers
Related