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