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

Python code coverage for Lib/test/test_tools/test_sundry.py

#countcontent
1n/a"""Tests for scripts in the Tools directory.
2n/a
3n/aThis file contains extremely basic regression tests for the scripts found in
4n/athe Tools directory of a Python checkout or tarball which don't have separate
5n/atests of their own, such as h2py.py.
6n/a"""
7n/a
8n/aimport os
9n/aimport sys
10n/aimport unittest
11n/afrom test import support
12n/a
13n/afrom test.test_tools import scriptsdir, import_tool, skip_if_missing
14n/a
15n/askip_if_missing()
16n/a
17n/aclass TestSundryScripts(unittest.TestCase):
18n/a # At least make sure the rest don't have syntax errors. When tests are
19n/a # added for a script it should be added to the whitelist below.
20n/a
21n/a # scripts that have independent tests.
22n/a whitelist = ['reindent', 'pdeps', 'gprof2html', 'md5sum']
23n/a # scripts that can't be imported without running
24n/a blacklist = ['make_ctype']
25n/a # scripts that use windows-only modules
26n/a windows_only = ['win_add2path']
27n/a # blacklisted for other reasons
28n/a other = ['analyze_dxp']
29n/a
30n/a skiplist = blacklist + whitelist + windows_only + other
31n/a
32n/a def test_sundry(self):
33n/a for fn in os.listdir(scriptsdir):
34n/a name = fn[:-3]
35n/a if fn.endswith('.py') and name not in self.skiplist:
36n/a import_tool(name)
37n/a
38n/a @unittest.skipIf(sys.platform != "win32", "Windows-only test")
39n/a def test_sundry_windows(self):
40n/a for name in self.windows_only:
41n/a import_tool(name)
42n/a
43n/a @unittest.skipIf(not support.threading, "test requires _thread module")
44n/a def test_analyze_dxp_import(self):
45n/a if hasattr(sys, 'getdxp'):
46n/a import_tool('analyze_dxp')
47n/a else:
48n/a with self.assertRaises(RuntimeError):
49n/a import_tool('analyze_dxp')
50n/a
51n/a
52n/aif __name__ == '__main__':
53n/a unittest.main()