August 2018
Beginner
160 pages
4h 8m
English
Sometimes, developers leave print statements laying around by mistake, or even on purpose, to be used later for debugging. Some applications also may write to stdout or stderr as part of their normal operation or logging.
All that output would make understanding the test suite display much harder. For this reason, by default, pytest captures all output written to stdout and stderr automatically.
Consider this function to compute a hash of some text given to it that has some debugging code left on it:
import hashlibdef commit_hash(contents): size = len(contents) print('content size', size) hash_contents = str(size) + '\0' + contents result = hashlib.sha1(hash_contents.encode('UTF-8')).hexdigest() print(result) ...Read now
Unlock full access