]> git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Lib/distutils/tests/test_config_cmd.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / distutils / tests / test_config_cmd.py
1 """Tests for distutils.command.config."""
2 import unittest
3 import os
4 import sys
5 from test.test_support import run_unittest
6
7 from distutils.command.config import dump_file, config
8 from distutils.tests import support
9 from distutils import log
10
11 class ConfigTestCase(support.LoggingSilencer,
12 support.TempdirManager,
13 unittest.TestCase):
14
15 def _info(self, msg, *args):
16 for line in msg.splitlines():
17 self._logs.append(line)
18
19 def setUp(self):
20 super(ConfigTestCase, self).setUp()
21 self._logs = []
22 self.old_log = log.info
23 log.info = self._info
24
25 def tearDown(self):
26 log.info = self.old_log
27 super(ConfigTestCase, self).tearDown()
28
29 def test_dump_file(self):
30 this_file = os.path.splitext(__file__)[0] + '.py'
31 f = open(this_file)
32 try:
33 numlines = len(f.readlines())
34 finally:
35 f.close()
36
37 dump_file(this_file, 'I am the header')
38 self.assertEqual(len(self._logs), numlines+1)
39
40 def test_search_cpp(self):
41 if sys.platform == 'win32':
42 return
43 pkg_dir, dist = self.create_dist()
44 cmd = config(dist)
45
46 # simple pattern searches
47 match = cmd.search_cpp(pattern='xxx', body='// xxx')
48 self.assertEqual(match, 0)
49
50 match = cmd.search_cpp(pattern='_configtest', body='// xxx')
51 self.assertEqual(match, 1)
52
53 def test_finalize_options(self):
54 # finalize_options does a bit of transformation
55 # on options
56 pkg_dir, dist = self.create_dist()
57 cmd = config(dist)
58 cmd.include_dirs = 'one%stwo' % os.pathsep
59 cmd.libraries = 'one'
60 cmd.library_dirs = 'three%sfour' % os.pathsep
61 cmd.ensure_finalized()
62
63 self.assertEqual(cmd.include_dirs, ['one', 'two'])
64 self.assertEqual(cmd.libraries, ['one'])
65 self.assertEqual(cmd.library_dirs, ['three', 'four'])
66
67 def test_clean(self):
68 # _clean removes files
69 tmp_dir = self.mkdtemp()
70 f1 = os.path.join(tmp_dir, 'one')
71 f2 = os.path.join(tmp_dir, 'two')
72
73 self.write_file(f1, 'xxx')
74 self.write_file(f2, 'xxx')
75
76 for f in (f1, f2):
77 self.assertTrue(os.path.exists(f))
78
79 pkg_dir, dist = self.create_dist()
80 cmd = config(dist)
81 cmd._clean(f1, f2)
82
83 for f in (f1, f2):
84 self.assertTrue(not os.path.exists(f))
85
86 def test_suite():
87 return unittest.makeSuite(ConfigTestCase)
88
89 if __name__ == "__main__":
90 run_unittest(test_suite())