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

eric.araujo python-checkins at python.org
Mon Sep 19 15:12:39 CEST 2011


http://hg.python.org/distutils2/rev/944804585806
changeset:   1158:944804585806
user:        Éric Araujo <merwok at netwok.org>
date:        Mon Sep 19 02:41:00 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:
  distutils2/tests/test_command_install_dist.py |  20 +++++----
  1 files changed, 11 insertions(+), 9 deletions(-)


diff --git a/distutils2/tests/test_command_install_dist.py b/distutils2/tests/test_command_install_dist.py
--- a/distutils2/tests/test_command_install_dist.py
+++ b/distutils2/tests/test_command_install_dist.py
@@ -175,24 +175,26 @@
     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'])
+        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
         f = open(cmd.record)
-        lines = f.readlines()
-        f.close()
-        self.assertEqual(len(lines), 4)
+        try:
+            content = f.read()
+        finally:
+            f.close()
 
+        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/distutils2


More information about the Python-checkins mailing list