summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/tests/test_build_scripts.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-11-03 18:27:27 (GMT)
committerGitHub <noreply@github.com>2022-11-03 18:27:27 (GMT)
commit0faa0ba240e815614e5a2900e48007acac41b214 (patch)
tree20b8346df4331716aba051d6e05e039318176ba3 /Lib/distutils/tests/test_build_scripts.py
parentb07f546ea3a574bc3016fb023c157c65a47f4849 (diff)
downloadcpython-0faa0ba240e815614e5a2900e48007acac41b214.zip
cpython-0faa0ba240e815614e5a2900e48007acac41b214.tar.gz
cpython-0faa0ba240e815614e5a2900e48007acac41b214.tar.bz2
gh-92584: Remove the distutils package (#99061)
Remove the distutils package. It was deprecated in Python 3.10 by PEP 632 "Deprecate distutils module". For projects still using distutils and cannot be updated to something else, the setuptools project can be installed: it still provides distutils. * Remove Lib/distutils/ directory * Remove test_distutils * Remove references to distutils * Skip test_check_c_globals and test_peg_generator since they use distutils
Diffstat (limited to 'Lib/distutils/tests/test_build_scripts.py')
-rw-r--r--Lib/distutils/tests/test_build_scripts.py112
1 files changed, 0 insertions, 112 deletions
diff --git a/Lib/distutils/tests/test_build_scripts.py b/Lib/distutils/tests/test_build_scripts.py
deleted file mode 100644
index f299e51..0000000
--- a/Lib/distutils/tests/test_build_scripts.py
+++ /dev/null
@@ -1,112 +0,0 @@
-"""Tests for distutils.command.build_scripts."""
-
-import os
-import unittest
-
-from distutils.command.build_scripts import build_scripts
-from distutils.core import Distribution
-from distutils import sysconfig
-
-from distutils.tests import support
-from test.support import run_unittest
-
-
-class BuildScriptsTestCase(support.TempdirManager,
- support.LoggingSilencer,
- unittest.TestCase):
-
- def test_default_settings(self):
- cmd = self.get_build_scripts_cmd("/foo/bar", [])
- self.assertFalse(cmd.force)
- self.assertIsNone(cmd.build_dir)
-
- cmd.finalize_options()
-
- self.assertTrue(cmd.force)
- self.assertEqual(cmd.build_dir, "/foo/bar")
-
- def test_build(self):
- source = self.mkdtemp()
- target = self.mkdtemp()
- expected = self.write_sample_scripts(source)
-
- cmd = self.get_build_scripts_cmd(target,
- [os.path.join(source, fn)
- for fn in expected])
- cmd.finalize_options()
- cmd.run()
-
- built = os.listdir(target)
- for name in expected:
- self.assertIn(name, built)
-
- def get_build_scripts_cmd(self, target, scripts):
- import sys
- dist = Distribution()
- dist.scripts = scripts
- dist.command_obj["build"] = support.DummyCommand(
- build_scripts=target,
- force=1,
- executable=sys.executable
- )
- return build_scripts(dist)
-
- def write_sample_scripts(self, dir):
- expected = []
- expected.append("script1.py")
- self.write_script(dir, "script1.py",
- ("#! /usr/bin/env python2.3\n"
- "# bogus script w/ Python sh-bang\n"
- "pass\n"))
- expected.append("script2.py")
- self.write_script(dir, "script2.py",
- ("#!/usr/bin/python\n"
- "# bogus script w/ Python sh-bang\n"
- "pass\n"))
- expected.append("shell.sh")
- self.write_script(dir, "shell.sh",
- ("#!/bin/sh\n"
- "# bogus shell script w/ sh-bang\n"
- "exit 0\n"))
- return expected
-
- def write_script(self, dir, name, text):
- f = open(os.path.join(dir, name), "w")
- try:
- f.write(text)
- finally:
- f.close()
-
- def test_version_int(self):
- source = self.mkdtemp()
- target = self.mkdtemp()
- expected = self.write_sample_scripts(source)
-
-
- cmd = self.get_build_scripts_cmd(target,
- [os.path.join(source, fn)
- for fn in expected])
- cmd.finalize_options()
-
- # http://bugs.python.org/issue4524
- #
- # On linux-g++-32 with command line `./configure --enable-ipv6
- # --with-suffix=3`, python is compiled okay but the build scripts
- # failed when writing the name of the executable
- old = sysconfig.get_config_vars().get('VERSION')
- sysconfig._config_vars['VERSION'] = 4
- try:
- cmd.run()
- finally:
- if old is not None:
- sysconfig._config_vars['VERSION'] = old
-
- built = os.listdir(target)
- for name in expected:
- self.assertIn(name, built)
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromTestCase(BuildScriptsTestCase)
-
-if __name__ == "__main__":
- run_unittest(test_suite())