]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Lib/distutils/tests/test_config_cmd.py
1 """Tests for distutils.command.config."""
5 from test
.test_support
import run_unittest
7 from distutils
.command
.config
import dump_file
, config
8 from distutils
.tests
import support
9 from distutils
import log
11 class ConfigTestCase(support
.LoggingSilencer
,
12 support
.TempdirManager
,
15 def _info(self
, msg
, *args
):
16 for line
in msg
.splitlines():
17 self
._logs
.append(line
)
20 super(ConfigTestCase
, self
).setUp()
22 self
.old_log
= log
.info
26 log
.info
= self
.old_log
27 super(ConfigTestCase
, self
).tearDown()
29 def test_dump_file(self
):
30 this_file
= os
.path
.splitext(__file__
)[0] + '.py'
33 numlines
= len(f
.readlines())
37 dump_file(this_file
, 'I am the header')
38 self
.assertEqual(len(self
._logs
), numlines
+1)
40 def test_search_cpp(self
):
41 if sys
.platform
== 'win32':
43 pkg_dir
, dist
= self
.create_dist()
46 # simple pattern searches
47 match
= cmd
.search_cpp(pattern
='xxx', body
='// xxx')
48 self
.assertEqual(match
, 0)
50 match
= cmd
.search_cpp(pattern
='_configtest', body
='// xxx')
51 self
.assertEqual(match
, 1)
53 def test_finalize_options(self
):
54 # finalize_options does a bit of transformation
56 pkg_dir
, dist
= self
.create_dist()
58 cmd
.include_dirs
= 'one%stwo' % os
.pathsep
60 cmd
.library_dirs
= 'three%sfour' % os
.pathsep
61 cmd
.ensure_finalized()
63 self
.assertEqual(cmd
.include_dirs
, ['one', 'two'])
64 self
.assertEqual(cmd
.libraries
, ['one'])
65 self
.assertEqual(cmd
.library_dirs
, ['three', 'four'])
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')
73 self
.write_file(f1
, 'xxx')
74 self
.write_file(f2
, 'xxx')
77 self
.assertTrue(os
.path
.exists(f
))
79 pkg_dir
, dist
= self
.create_dist()
84 self
.assertTrue(not os
.path
.exists(f
))
87 return unittest
.makeSuite(ConfigTestCase
)
89 if __name__
== "__main__":
90 run_unittest(test_suite())