+++ /dev/null
-"""Tests for distutils.command.install_data."""\r
-import sys\r
-import os\r
-import unittest\r
-import getpass\r
-\r
-from distutils.command.install_data import install_data\r
-from distutils.tests import support\r
-from test.test_support import run_unittest\r
-\r
-class InstallDataTestCase(support.TempdirManager,\r
- support.LoggingSilencer,\r
- support.EnvironGuard,\r
- unittest.TestCase):\r
-\r
- def test_simple_run(self):\r
- pkg_dir, dist = self.create_dist()\r
- cmd = install_data(dist)\r
- cmd.install_dir = inst = os.path.join(pkg_dir, 'inst')\r
-\r
- # data_files can contain\r
- # - simple files\r
- # - a tuple with a path, and a list of file\r
- one = os.path.join(pkg_dir, 'one')\r
- self.write_file(one, 'xxx')\r
- inst2 = os.path.join(pkg_dir, 'inst2')\r
- two = os.path.join(pkg_dir, 'two')\r
- self.write_file(two, 'xxx')\r
-\r
- cmd.data_files = [one, (inst2, [two])]\r
- self.assertEqual(cmd.get_inputs(), [one, (inst2, [two])])\r
-\r
- # let's run the command\r
- cmd.ensure_finalized()\r
- cmd.run()\r
-\r
- # let's check the result\r
- self.assertEqual(len(cmd.get_outputs()), 2)\r
- rtwo = os.path.split(two)[-1]\r
- self.assertTrue(os.path.exists(os.path.join(inst2, rtwo)))\r
- rone = os.path.split(one)[-1]\r
- self.assertTrue(os.path.exists(os.path.join(inst, rone)))\r
- cmd.outfiles = []\r
-\r
- # let's try with warn_dir one\r
- cmd.warn_dir = 1\r
- cmd.ensure_finalized()\r
- cmd.run()\r
-\r
- # let's check the result\r
- self.assertEqual(len(cmd.get_outputs()), 2)\r
- self.assertTrue(os.path.exists(os.path.join(inst2, rtwo)))\r
- self.assertTrue(os.path.exists(os.path.join(inst, rone)))\r
- cmd.outfiles = []\r
-\r
- # now using root and empty dir\r
- cmd.root = os.path.join(pkg_dir, 'root')\r
- inst3 = os.path.join(cmd.install_dir, 'inst3')\r
- inst4 = os.path.join(pkg_dir, 'inst4')\r
- three = os.path.join(cmd.install_dir, 'three')\r
- self.write_file(three, 'xx')\r
- cmd.data_files = [one, (inst2, [two]),\r
- ('inst3', [three]),\r
- (inst4, [])]\r
- cmd.ensure_finalized()\r
- cmd.run()\r
-\r
- # let's check the result\r
- self.assertEqual(len(cmd.get_outputs()), 4)\r
- self.assertTrue(os.path.exists(os.path.join(inst2, rtwo)))\r
- self.assertTrue(os.path.exists(os.path.join(inst, rone)))\r
-\r
-def test_suite():\r
- return unittest.makeSuite(InstallDataTestCase)\r
-\r
-if __name__ == "__main__":\r
- run_unittest(test_suite())\r