Increasing coverage with try-except-finally and a context-manager
- by Daan Timmer
This is the flow that I have in my program
277: try:
278: with open(r"c:\afile.txt", "w") as aFile:
...: pass # write data
329: except IOError as ex:
...: print ex
332: finally:
333: if os.path.exists(r"c:\afile.txt"):
334: shutil.copy(r"c:\afile.txt", r"c:\dest.txt")
I've got all paths covered except for from line 278 to line 333
I got a normal happy-flow.
I stubbed __builtin__.open to raise IOError when the open is called with said file name
But how do I go from 278 to 333. Is this even possible?
Additional information:
- using coverage.py 3.4 (only listing 3.5, we can't currently upgrade to 3.5)