[Python-checkins] cpython: Rework test_old_record a bit to make the test more exact

eric.araujo python-checkins at python.org
Sat Aug 20 20:02:36 CEST 2011


http://hg.python.org/cpython/rev/a74eecc48c13
changeset:   71996:a74eecc48c13
user:        Éric Araujo <merwok at netwok.org>
date:        Sat Aug 20 07:34:43 2011 +0200
summary:
  Rework test_old_record a bit to make the test more exact
(i.e. to check the files found are what we expect)

files:
  Lib/packaging/tests/test_command_install_dist.py |  26 +++++-----
  1 files changed, 13 insertions(+), 13 deletions(-)


diff --git a/Lib/packaging/tests/test_command_install_dist.py b/Lib/packaging/tests/test_command_install_dist.py
--- 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 @@
     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

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list