]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.2/Lib/distutils/tests/test_install_data.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / distutils / tests / test_install_data.py
CommitLineData
4710c53d 1"""Tests for distutils.command.install_data."""\r
2import sys\r
3import os\r
4import unittest\r
5import getpass\r
6\r
7from distutils.command.install_data import install_data\r
8from distutils.tests import support\r
9from test.test_support import run_unittest\r
10\r
11class InstallDataTestCase(support.TempdirManager,\r
12 support.LoggingSilencer,\r
13 support.EnvironGuard,\r
14 unittest.TestCase):\r
15\r
16 def test_simple_run(self):\r
17 pkg_dir, dist = self.create_dist()\r
18 cmd = install_data(dist)\r
19 cmd.install_dir = inst = os.path.join(pkg_dir, 'inst')\r
20\r
21 # data_files can contain\r
22 # - simple files\r
23 # - a tuple with a path, and a list of file\r
24 one = os.path.join(pkg_dir, 'one')\r
25 self.write_file(one, 'xxx')\r
26 inst2 = os.path.join(pkg_dir, 'inst2')\r
27 two = os.path.join(pkg_dir, 'two')\r
28 self.write_file(two, 'xxx')\r
29\r
30 cmd.data_files = [one, (inst2, [two])]\r
31 self.assertEqual(cmd.get_inputs(), [one, (inst2, [two])])\r
32\r
33 # let's run the command\r
34 cmd.ensure_finalized()\r
35 cmd.run()\r
36\r
37 # let's check the result\r
38 self.assertEqual(len(cmd.get_outputs()), 2)\r
39 rtwo = os.path.split(two)[-1]\r
40 self.assertTrue(os.path.exists(os.path.join(inst2, rtwo)))\r
41 rone = os.path.split(one)[-1]\r
42 self.assertTrue(os.path.exists(os.path.join(inst, rone)))\r
43 cmd.outfiles = []\r
44\r
45 # let's try with warn_dir one\r
46 cmd.warn_dir = 1\r
47 cmd.ensure_finalized()\r
48 cmd.run()\r
49\r
50 # let's check the result\r
51 self.assertEqual(len(cmd.get_outputs()), 2)\r
52 self.assertTrue(os.path.exists(os.path.join(inst2, rtwo)))\r
53 self.assertTrue(os.path.exists(os.path.join(inst, rone)))\r
54 cmd.outfiles = []\r
55\r
56 # now using root and empty dir\r
57 cmd.root = os.path.join(pkg_dir, 'root')\r
58 inst3 = os.path.join(cmd.install_dir, 'inst3')\r
59 inst4 = os.path.join(pkg_dir, 'inst4')\r
60 three = os.path.join(cmd.install_dir, 'three')\r
61 self.write_file(three, 'xx')\r
62 cmd.data_files = [one, (inst2, [two]),\r
63 ('inst3', [three]),\r
64 (inst4, [])]\r
65 cmd.ensure_finalized()\r
66 cmd.run()\r
67\r
68 # let's check the result\r
69 self.assertEqual(len(cmd.get_outputs()), 4)\r
70 self.assertTrue(os.path.exists(os.path.join(inst2, rtwo)))\r
71 self.assertTrue(os.path.exists(os.path.join(inst, rone)))\r
72\r
73def test_suite():\r
74 return unittest.makeSuite(InstallDataTestCase)\r
75\r
76if __name__ == "__main__":\r
77 run_unittest(test_suite())\r