Rev 2827: Use assertIsSameRealPath to avoid OSX aliasing (specifically /tmp in file:///v/home/vila/src/bugs/osx.pass.test.suite/

Vincent Ladeuil v.ladeuil+lp at free.fr
Mon Sep 17 13:34:33 BST 2007


At file:///v/home/vila/src/bugs/osx.pass.test.suite/

------------------------------------------------------------
revno: 2827
revision-id: v.ladeuil+lp at free.fr-20070917123431-065warglku51y822
parent: v.ladeuil+lp at free.fr-20070915110822-qamlabd07hmima6i
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: osx.pass.test.suite
timestamp: Mon 2007-09-17 14:34:31 +0200
message:
  Use assertIsSameRealPath to avoid OSX aliasing (specifically /tmp
  -> /private/tmp).
  
  * bzrlib/tests/__init__.py:
  (TestCase.assertIsSameRealPath): New method resolving symlinks
  before comparing paths.
  
  * bzrlib/tests/test_selftest.py:
  (TestTestCaseInTempDir.test_home_is_not_working,
  TestTestCaseWithMemoryTransport.test_home_is_non_existant_dir_under_root,
  TestTestCaseWithMemoryTransport.test_cwd_is_TEST_ROOT): Use
  assertIsSameRealPath.
  
  * bzrlib/tests/test_plugins.py:
  (TestPlugins.test_trivial_plugin_get_path): Use assertIsSameRealPath.
  
  * bzrlib/tests/test_sftp_transport.py:
  (SFTPTransportTestRelative.test__remote_path): The test should be
  totally rewritten for OSX. Marking it as know failure in the
  interim.
modified:
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/test_plugins.py   plugins.py-20050622075746-32002b55e5e943e9
  bzrlib/tests/test_selftest.py  test_selftest.py-20051202044319-c110a115d8c0456a
  bzrlib/tests/test_sftp_transport.py testsftp.py-20051027032739-247570325fec7e7e
-------------- next part --------------
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2007-09-05 08:18:57 +0000
+++ b/bzrlib/tests/__init__.py	2007-09-17 12:34:31 +0000
@@ -983,6 +983,11 @@
         self.assertEqual(mode, actual_mode,
             'mode of %r incorrect (%o != %o)' % (path, mode, actual_mode))
 
+    def assertIsSameRealPath(self, path1, path2):
+        """Fail if path1 and path2 points to different files"""
+        self.assertEqual(bzrlib.osutils.realpath(path1),
+                         bzrlib.osutils.realpath(path2))
+
     def assertIsInstance(self, obj, kls):
         """Fail if obj is not an instance of kls"""
         if not isinstance(obj, kls):

=== modified file 'bzrlib/tests/test_plugins.py'
--- a/bzrlib/tests/test_plugins.py	2007-08-29 01:16:53 +0000
+++ b/bzrlib/tests/test_plugins.py	2007-09-17 12:34:31 +0000
@@ -241,7 +241,7 @@
         plugins = bzrlib.plugin.plugins()
         plugin = plugins['plugin']
         plugin_path = self.test_dir + '/plugin.py'
-        self.assertEqual(plugin_path, plugin.path())
+        self.assertIsSameRealPath(plugin_path, plugin.path())
 
     def test_no_test_suite_gives_None_for_test_suite(self):
         self.setup_plugin()

=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py	2007-09-03 04:35:49 +0000
+++ b/bzrlib/tests/test_selftest.py	2007-09-17 12:34:31 +0000
@@ -564,8 +564,8 @@
     def test_home_is_not_working(self):
         self.assertNotEqual(self.test_dir, self.test_home_dir)
         cwd = osutils.getcwd()
-        self.assertEqual(self.test_dir, cwd)
-        self.assertEqual(self.test_home_dir, os.environ['HOME'])
+        self.assertIsSameRealPath(self.test_dir, cwd)
+        self.assertIsSameRealPath(self.test_home_dir, os.environ['HOME'])
 
 
 class TestTestCaseWithMemoryTransport(TestCaseWithMemoryTransport):
@@ -579,14 +579,15 @@
         few tests should need to do that), and having a missing dir as home is
         an effective way to ensure that this is the case.
         """
-        self.assertEqual(self.TEST_ROOT + "/MemoryTransportMissingHomeDir",
+        self.assertIsSameRealPath(
+            self.TEST_ROOT + "/MemoryTransportMissingHomeDir",
             self.test_home_dir)
-        self.assertEqual(self.test_home_dir, os.environ['HOME'])
+        self.assertIsSameRealPath(self.test_home_dir, os.environ['HOME'])
         
     def test_cwd_is_TEST_ROOT(self):
-        self.assertEqual(self.test_dir, self.TEST_ROOT)
+        self.assertIsSameRealPath(self.test_dir, self.TEST_ROOT)
         cwd = osutils.getcwd()
-        self.assertEqual(self.test_dir, cwd)
+        self.assertIsSameRealPath(self.test_dir, cwd)
 
     def test_make_branch_and_memory_tree(self):
         """In TestCaseWithMemoryTransport we should not make the branch on disk.

=== modified file 'bzrlib/tests/test_sftp_transport.py'
--- a/bzrlib/tests/test_sftp_transport.py	2007-09-14 09:38:52 +0000
+++ b/bzrlib/tests/test_sftp_transport.py	2007-09-17 12:34:31 +0000
@@ -108,6 +108,9 @@
     """Test the SFTP transport with homedir based relative paths."""
 
     def test__remote_path(self):
+        if sys.platform == 'darwin':
+            self.knownFailure("Mac OSX use /private/tmp instead of /tmp,"
+                              " testing self.test_dir is not pertinent")
         t = self.get_transport()
         # This test require unix-like absolute path
         test_dir = self.test_dir



More information about the bazaar-commits mailing list