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