]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Lib/distutils/tests/test_install_data.py
1 """Tests for distutils.command.install_data."""
7 from distutils
.command
.install_data
import install_data
8 from distutils
.tests
import support
9 from test
.test_support
import run_unittest
11 class InstallDataTestCase(support
.TempdirManager
,
12 support
.LoggingSilencer
,
16 def test_simple_run(self
):
17 pkg_dir
, dist
= self
.create_dist()
18 cmd
= install_data(dist
)
19 cmd
.install_dir
= inst
= os
.path
.join(pkg_dir
, 'inst')
21 # data_files can contain
23 # - a tuple with a path, and a list of file
24 one
= os
.path
.join(pkg_dir
, 'one')
25 self
.write_file(one
, 'xxx')
26 inst2
= os
.path
.join(pkg_dir
, 'inst2')
27 two
= os
.path
.join(pkg_dir
, 'two')
28 self
.write_file(two
, 'xxx')
30 cmd
.data_files
= [one
, (inst2
, [two
])]
31 self
.assertEqual(cmd
.get_inputs(), [one
, (inst2
, [two
])])
33 # let's run the command
34 cmd
.ensure_finalized()
37 # let's check the result
38 self
.assertEqual(len(cmd
.get_outputs()), 2)
39 rtwo
= os
.path
.split(two
)[-1]
40 self
.assertTrue(os
.path
.exists(os
.path
.join(inst2
, rtwo
)))
41 rone
= os
.path
.split(one
)[-1]
42 self
.assertTrue(os
.path
.exists(os
.path
.join(inst
, rone
)))
45 # let's try with warn_dir one
47 cmd
.ensure_finalized()
50 # let's check the result
51 self
.assertEqual(len(cmd
.get_outputs()), 2)
52 self
.assertTrue(os
.path
.exists(os
.path
.join(inst2
, rtwo
)))
53 self
.assertTrue(os
.path
.exists(os
.path
.join(inst
, rone
)))
56 # now using root and empty dir
57 cmd
.root
= os
.path
.join(pkg_dir
, 'root')
58 inst3
= os
.path
.join(cmd
.install_dir
, 'inst3')
59 inst4
= os
.path
.join(pkg_dir
, 'inst4')
60 three
= os
.path
.join(cmd
.install_dir
, 'three')
61 self
.write_file(three
, 'xx')
62 cmd
.data_files
= [one
, (inst2
, [two
]),
65 cmd
.ensure_finalized()
68 # let's check the result
69 self
.assertEqual(len(cmd
.get_outputs()), 4)
70 self
.assertTrue(os
.path
.exists(os
.path
.join(inst2
, rtwo
)))
71 self
.assertTrue(os
.path
.exists(os
.path
.join(inst
, rone
)))
74 return unittest
.makeSuite(InstallDataTestCase
)
76 if __name__
== "__main__":
77 run_unittest(test_suite())