I am testing a Python module that contains the following code snippet.
r, w = os.pipe()
pid = os.fork()
if pid:
os.close(w)
r = os.fdopen(r)
self.ofs.put_stream(bucket, label, r, metadata)
os.waitpid(pid, 0)
else:
os.close(r)
w = os.fdopen(w, 'w')
pickle.dump(obj, w)
w.close()
sys.exit(0)
return result
All tests pass, but there are difficulties regarding sys.exit(0). When sys.exit(0)executed, it raises SystemExit, which is intercepted py.testand reported as an error in the console.
I don’t understand in detail what py.testit is doing internally, but it looks like it goes ahead and ultimately ignores such an event caused by a child process. In the end, all the tests pass, which is good.
But I want to have clean output in the console.
Is there any way to py.testget a clean output?
For information:
- Debian Jessie, kernel 3.12.6
- Python 2.7.6
- pytest 2.5.2
Thank:)