<div class="gmail_quote">On Fri, Nov 26, 2010 at 12:44, hirokazu.yamamoto <span dir="ltr">&lt;<a href="mailto:python-checkins@python.org">python-checkins@python.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Author: hirokazu.yamamoto<br>
Date: Fri Nov 26 19:44:28 2010<br>
New Revision: 86817<br>
<br>
Log:<br>
Now can reproduce the error on AMD64 Windows Server 2008<br>
even where os.symlink is not supported.<br>
<br>
<br>
Modified:<br>
   python/branches/py3k-stat-on-windows/Lib/test/test_shutil.py<br>
<br>
Modified: python/branches/py3k-stat-on-windows/Lib/test/test_shutil.py<br>
==============================================================================<br>
--- python/branches/py3k-stat-on-windows/Lib/test/test_shutil.py        (original)<br>
+++ python/branches/py3k-stat-on-windows/Lib/test/test_shutil.py        Fri Nov 26 19:44:28 2010<br>
@@ -271,24 +271,32 @@<br>
             shutil.rmtree(src_dir)<br>
             shutil.rmtree(os.path.dirname(dst_dir))<br>
<br>
-    @support.skip_unless_symlink<br>
+    @unittest.skipUnless(hasattr(os, &#39;link&#39;), &#39;requires os.link&#39;)<br>
     def test_dont_copy_file_onto_link_to_itself(self):<br>
         # bug 851123.<br>
         os.mkdir(TESTFN)<br>
         src = os.path.join(TESTFN, &#39;cheese&#39;)<br>
         dst = os.path.join(TESTFN, &#39;shop&#39;)<br>
         try:<br>
-            f = open(src, &#39;w&#39;)<br>
-            f.write(&#39;cheddar&#39;)<br>
-            f.close()<br>
-<br>
-            if hasattr(os, &quot;link&quot;):<br>
-                os.link(src, dst)<br>
-                self.assertRaises(shutil.Error, shutil.copyfile, src, dst)<br>
-                with open(src, &#39;r&#39;) as f:<br>
-                    self.assertEqual(f.read(), &#39;cheddar&#39;)<br>
-                os.remove(dst)<br>
+            with open(src, &#39;w&#39;) as f:<br>
+                f.write(&#39;cheddar&#39;)<br>
+            os.link(src, dst)<br>
+            self.assertRaises(shutil.Error, shutil.copyfile, src, dst)<br>
+            with open(src, &#39;r&#39;) as f:<br>
+                self.assertEqual(f.read(), &#39;cheddar&#39;)<br>
+            os.remove(dst)<br>
+        finally:<br>
+            shutil.rmtree(TESTFN, ignore_errors=True)<br>
<br>
+    @support.skip_unless_symlink<br>
+    def test_dont_copy_file_onto_symlink_to_itself(self):<br>
+        # bug 851123.<br>
+        os.mkdir(TESTFN)<br>
+        src = os.path.join(TESTFN, &#39;cheese&#39;)<br>
+        dst = os.path.join(TESTFN, &#39;shop&#39;)<br>
+        try:<br>
+            with open(src, &#39;w&#39;) as f:<br>
+                f.write(&#39;cheddar&#39;)<br>
             # Using `src` here would mean we end up with a symlink pointing<br>
             # to TESTFN/TESTFN/cheese, while it should point at<br>
             # TESTFN/cheese.<br>
@@ -298,10 +306,7 @@<br>
                 self.assertEqual(f.read(), &#39;cheddar&#39;)<br>
             os.remove(dst)<br>
         finally:<br>
-            try:<br>
-                shutil.rmtree(TESTFN)<br>
-            except OSError:<br>
-                pass<br>
+            shutil.rmtree(TESTFN, ignore_errors=True)<br>
<br>
     @support.skip_unless_symlink<br>
     def test_rmtree_on_symlink(self):</blockquote><div><br></div><div>You might be working on something slightly different, but I have an issue created for the failure of that test: <a href="http://bugs.python.org/issue10540">http://bugs.python.org/issue10540</a></div>
<div><br></div><div>It slipped past me because I was only running the test suite as a regular user without the required symlink privilege, so the test was skipped. That Server 2008 build slave runs the test suite as administrator, so it was running that test and going into the os.link block, which it didn&#39;t do until r86733.</div>
</div>