diff options
| author | FELD Boris <lothiraldan@gmail.com> | 2011-01-30 14:42:59 +0100 |
|---|---|---|
| committer | FELD Boris <lothiraldan@gmail.com> | 2011-01-30 14:42:59 +0100 |
| commit | 57b7580dada83b93bcea4f77b3c50069399fc488 (patch) | |
| tree | a1459ccd2f3478d8b92fd70917966c0b144148eb | |
| parent | 162c4cae8806f33a29903c01cfd7fc9a635429f5 (diff) | |
| download | disutils2-57b7580dada83b93bcea4f77b3c50069399fc488.tar.gz | |
Fix last bug, check that data file not exists at the same path and has the same content.
| -rw-r--r-- | distutils2/command/install_data.py | 7 | ||||
| -rw-r--r-- | distutils2/tests/test_command_install_data.py | 29 |
2 files changed, 29 insertions, 7 deletions
diff --git a/distutils2/command/install_data.py b/distutils2/command/install_data.py index 8ef089d..b7a9498 100644 --- a/distutils2/command/install_data.py +++ b/distutils2/command/install_data.py @@ -10,6 +10,7 @@ import os from distutils2.command.cmd import Command from distutils2.util import change_root, convert_path from distutils2._backport.sysconfig import get_paths, format_value +from distutils2._backport.shutil import Error class install_data(Command): @@ -47,7 +48,11 @@ class install_data(Command): dir_dest = os.path.abspath(os.path.dirname(destination)) self.mkpath(dir_dest) - (out, _) = self.copy_file(file[0], dir_dest) + try: + (out, _) = self.copy_file(file[0], dir_dest) + except Error, e: + self.warn(e.message) + out = destination self.outfiles.append(out) self.data_files_out.append((file[0], destination)) diff --git a/distutils2/tests/test_command_install_data.py b/distutils2/tests/test_command_install_data.py index c24d304..b02a7d4 100644 --- a/distutils2/tests/test_command_install_data.py +++ b/distutils2/tests/test_command_install_data.py @@ -1,4 +1,5 @@ """Tests for distutils.command.install_data.""" +import cmd import os from distutils2.command.install_data import install_data @@ -10,18 +11,29 @@ class InstallDataTestCase(support.TempdirManager, unittest.TestCase): def test_simple_run(self): + from distutils2._backport.sysconfig import _SCHEMES as sysconfig_SCHEMES + from distutils2._backport.sysconfig import _get_default_scheme + #dirty but hit marmoute + + old_scheme = sysconfig_SCHEMES + pkg_dir, dist = self.create_dist() cmd = install_data(dist) cmd.install_dir = inst = os.path.join(pkg_dir, 'inst') + sysconfig_SCHEMES.set(_get_default_scheme(), 'inst', + os.path.join(pkg_dir, 'inst')) + sysconfig_SCHEMES.set(_get_default_scheme(), 'inst2', + os.path.join(pkg_dir, 'inst2')) + one = os.path.join(pkg_dir, 'one') self.write_file(one, 'xxx') inst2 = os.path.join(pkg_dir, 'inst2') two = os.path.join(pkg_dir, 'two') self.write_file(two, 'xxx') - cmd.data_files = {'one' : '{appdata}/one', 'two' : '{appdata}/two'} - self.assertEqual(cmd.get_inputs(), [one, (inst2, [two])]) + cmd.data_files = {one : '{inst}/one', two : '{inst2}/two'} + self.assertItemsEqual(cmd.get_inputs(), [one, two]) # let's run the command cmd.ensure_finalized() @@ -51,17 +63,22 @@ class InstallDataTestCase(support.TempdirManager, inst4 = os.path.join(pkg_dir, 'inst4') three = os.path.join(cmd.install_dir, 'three') self.write_file(three, 'xx') - cmd.data_files = [one, (inst2, [two]), - ('inst3', [three]), - (inst4, [])] + + sysconfig_SCHEMES.set(_get_default_scheme(), 'inst3', cmd.install_dir) + + cmd.data_files = {one : '{inst}/one', + two : '{inst2}/two', + three : '{inst3}/three'} cmd.ensure_finalized() cmd.run() # let's check the result - self.assertEqual(len(cmd.get_outputs()), 4) + self.assertEqual(len(cmd.get_outputs()), 3) self.assertTrue(os.path.exists(os.path.join(inst2, rtwo))) self.assertTrue(os.path.exists(os.path.join(inst, rone))) + sysconfig_SCHEMES = old_scheme + def test_suite(): return unittest.makeSuite(InstallDataTestCase) |
