test_install_data.py (2234B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\carbon\common\stdlib\distutils\tests\test_install_data.py 2 import sys 3 import os 4 import unittest 5 import getpass 6 from distutils.command.install_data import install_data 7 from distutils.tests import support 8 9 class InstallDataTestCase(support.TempdirManager, support.LoggingSilencer, support.EnvironGuard, unittest.TestCase): 10 11 def test_simple_run(self): 12 pkg_dir, dist = self.create_dist() 13 cmd = install_data(dist) 14 cmd.install_dir = inst = os.path.join(pkg_dir, 'inst') 15 one = os.path.join(pkg_dir, 'one') 16 self.write_file(one, 'xxx') 17 inst2 = os.path.join(pkg_dir, 'inst2') 18 two = os.path.join(pkg_dir, 'two') 19 self.write_file(two, 'xxx') 20 cmd.data_files = [one, (inst2, [two])] 21 self.assertEqual(cmd.get_inputs(), [one, (inst2, [two])]) 22 cmd.ensure_finalized() 23 cmd.run() 24 self.assertEqual(len(cmd.get_outputs()), 2) 25 rtwo = os.path.split(two)[-1] 26 self.assertTrue(os.path.exists(os.path.join(inst2, rtwo))) 27 rone = os.path.split(one)[-1] 28 self.assertTrue(os.path.exists(os.path.join(inst, rone))) 29 cmd.outfiles = [] 30 cmd.warn_dir = 1 31 cmd.ensure_finalized() 32 cmd.run() 33 self.assertEqual(len(cmd.get_outputs()), 2) 34 self.assertTrue(os.path.exists(os.path.join(inst2, rtwo))) 35 self.assertTrue(os.path.exists(os.path.join(inst, rone))) 36 cmd.outfiles = [] 37 cmd.root = os.path.join(pkg_dir, 'root') 38 inst3 = os.path.join(cmd.install_dir, 'inst3') 39 inst4 = os.path.join(pkg_dir, 'inst4') 40 three = os.path.join(cmd.install_dir, 'three') 41 self.write_file(three, 'xx') 42 cmd.data_files = [one, 43 (inst2, [two]), 44 ('inst3', [three]), 45 (inst4, [])] 46 cmd.ensure_finalized() 47 cmd.run() 48 self.assertEqual(len(cmd.get_outputs()), 4) 49 self.assertTrue(os.path.exists(os.path.join(inst2, rtwo))) 50 self.assertTrue(os.path.exists(os.path.join(inst, rone))) 51 52 53 def test_suite(): 54 return unittest.makeSuite(InstallDataTestCase) 55 56 57 if __name__ == '__main__': 58 unittest.main(defaultTest='test_suite')