Increasing coverage with try-except-finally and a context-manager
Posted
by
Daan Timmer
on Stack Overflow
See other posts from Stack Overflow
or by Daan Timmer
Published on 2012-04-12T11:19:29Z
Indexed on
2012/04/12
11:28 UTC
Read the original article
Hit count: 375
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)
© Stack Overflow or respective owner