diff --git a/Lib/packaging/tests/test_command_install_dist.py b/Lib/packaging/tests/test_command_install_dist.py index 7821a3afde7..c06a3c38bc4 100644 --- a/Lib/packaging/tests/test_command_install_dist.py +++ b/Lib/packaging/tests/test_command_install_dist.py @@ -2,22 +2,19 @@ import os import sys - from sysconfig import (get_scheme_names, get_config_vars, _SCHEMES, get_config_var, get_path) -_CONFIG_VARS = get_config_vars() - -from packaging.tests import captured_stdout - from packaging.command.install_dist import install_dist -from packaging.command import install_dist as install_module from packaging.dist import Distribution from packaging.errors import PackagingOptionError from packaging.tests import unittest, support +_CONFIG_VARS = get_config_vars() + + class InstallTestCase(support.TempdirManager, support.LoggingCatcher, unittest.TestCase): @@ -178,21 +175,24 @@ class InstallTestCase(support.TempdirManager, def test_old_record(self): # test pre-PEP 376 --record option (outside dist-info dir) install_dir = self.mkdtemp() - pkgdir, dist = self.create_dist() + project_dir, dist = self.create_dist(scripts=['hello']) + #self.addCleanup(os.chdir, os.getcwd()) + os.chdir(project_dir) + self.write_file('hello', "print('o hai')") - dist = Distribution() cmd = install_dist(dist) dist.command_obj['install_dist'] = cmd cmd.root = install_dir - cmd.record = os.path.join(pkgdir, 'filelist') + cmd.record = os.path.join(project_dir, 'filelist') cmd.ensure_finalized() cmd.run() - # let's check the record file was created with four - # lines, one for each .dist-info entry: METADATA, - # INSTALLER, REQUSTED, RECORD with open(cmd.record) as f: - self.assertEqual(len(f.readlines()), 4) + content = f.read() + + found = [os.path.basename(line) for line in content.splitlines()] + expected = ['hello', 'METADATA', 'INSTALLER', 'REQUESTED', 'RECORD'] + self.assertEqual(found, expected) # XXX test that fancy_getopt is okay with options named # record and no-record but unrelated