ยปCore Development>Code coverage>Lib/test/tf_inherit_check.py

Python code coverage for Lib/test/tf_inherit_check.py

#countcontent
1n/a# Helper script for test_tempfile.py. argv[2] is the number of a file
2n/a# descriptor which should _not_ be open. Check this by attempting to
3n/a# write to it -- if we succeed, something is wrong.
4n/a
5n/aimport sys
6n/aimport os
7n/afrom test.support import SuppressCrashReport
8n/a
9n/awith SuppressCrashReport():
10n/a verbose = (sys.argv[1] == 'v')
11n/a try:
12n/a fd = int(sys.argv[2])
13n/a
14n/a try:
15n/a os.write(fd, b"blat")
16n/a except OSError:
17n/a # Success -- could not write to fd.
18n/a sys.exit(0)
19n/a else:
20n/a if verbose:
21n/a sys.stderr.write("fd %d is open in child" % fd)
22n/a sys.exit(1)
23n/a
24n/a except Exception:
25n/a if verbose:
26n/a raise
27n/a sys.exit(1)