diff options
author | Fred Drake <fdrake@acm.org> | 2004-06-15 16:55:46 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2004-06-15 16:55:46 (GMT) |
commit | d0620dcf0034660177547d3363790fdc4ec5c3a6 (patch) | |
tree | 6f9c0e7d7d94f82b5d3bb38bb91ac201ffc2e81b /Lib/distutils/tests | |
parent | bb7c14461d8c69a9ffd70ae012b28ad35a9f3e78 (diff) | |
download | cpython-d0620dcf0034660177547d3363790fdc4ec5c3a6.zip cpython-d0620dcf0034660177547d3363790fdc4ec5c3a6.tar.gz cpython-d0620dcf0034660177547d3363790fdc4ec5c3a6.tar.bz2 |
add a test that actually installs some scripts
Diffstat (limited to 'Lib/distutils/tests')
-rw-r--r-- | Lib/distutils/tests/test_install_scripts.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/Lib/distutils/tests/test_install_scripts.py b/Lib/distutils/tests/test_install_scripts.py index f9a95ea..824f733 100644 --- a/Lib/distutils/tests/test_install_scripts.py +++ b/Lib/distutils/tests/test_install_scripts.py @@ -1,6 +1,8 @@ """Tests for distutils.command.install_scripts.""" import os +import shutil +import tempfile import unittest from distutils.command.install_scripts import install_scripts @@ -9,6 +11,23 @@ from distutils.core import Distribution class InstallScriptsTestCase(unittest.TestCase): + def setUp(self): + self.tempdirs = [] + + def tearDown(self): + while self.tempdirs: + d = self.tempdirs.pop() + shutil.rmtree(d) + + def mkdtemp(self): + """Create a temporary directory that will be cleaned up. + + Returns the path of the directory. + """ + d = tempfile.mkdtemp() + self.tempdirs.append(d) + return d + def test_default_settings(self): dist = Distribution() dist.command_obj["build"] = DummyCommand(build_scripts="/foo/bar") @@ -30,8 +49,45 @@ class InstallScriptsTestCase(unittest.TestCase): self.assertEqual(cmd.build_dir, "/foo/bar") self.assertEqual(cmd.install_dir, "/splat/funk") + def test_installation(self): + source = self.mkdtemp() + expected = [] + + def write_script(name, text): + expected.append(name) + f = open(os.path.join(source, name), "w") + f.write(text) + f.close() + + write_script("script1.py", ("#! /usr/bin/env python2.3\n" + "# bogus script w/ Python sh-bang\n" + "pass\n")) + write_script("script2.py", ("#!/usr/bin/python\n" + "# bogus script w/ Python sh-bang\n" + "pass\n")) + write_script("shell.sh", ("#!/bin/sh\n" + "# bogus shell script w/ sh-bang\n" + "exit 0\n")) + + target = self.mkdtemp() + dist = Distribution() + dist.command_obj["build"] = DummyCommand(build_scripts=source) + dist.command_obj["install"] = DummyCommand( + install_scripts=target, + force=1, + skip_build=1, + ) + cmd = install_scripts(dist) + cmd.finalize_options() + cmd.run() + + installed = os.listdir(target) + for name in expected: + self.assert_(name in installed) + class DummyCommand: + """Class to store options for retrieval via set_undefined_options().""" def __init__(self, **kwargs): for kw, val in kwargs.items(): |