[merge] follow up, fix the rest of the mac tests

Martin Pool mbp at canonical.com
Tue Jul 4 09:19:57 BST 2006


On  3 Jul 2006, John Arbash Meinel <john at arbash-meinel.com> wrote:
> I went ahead and fixed up the rest of the mac tests. It turned out the
> only thing left was to write a new getcwd() for Mac, which returns the
> normalized path. And then track down WorkingTree, since it was directly
> calling os.getcwdu() instead of osutils.getcwd().
> 
> Anyway, combining the previous patch with this patch means all tests
> pass on Mac.

+1, great work.

> +def _mac_getcwd():
> +    return unicodedata.normalize('NFKC', os.getcwdu())
> +
> +

It might have been covered by your previous patch, but it seems to me
there ought to be a comment or docstring (or HACKING entry) saying
when/why you should call osutils.getcwd rather than os.getcwd().

> +class TestMacFuncsDirs(TestCaseInTempDir):
> +    """Test mac special functions that require directories."""
> +
> +    def test_getcwd(self):
> +        # On Mac, this will actually create Ba\u030agfors
> +        # but chdir will still work, because it accepts both paths
> +        try:
> +            os.mkdir(u'B\xe5gfors')
> +        except UnicodeError:
> +            raise TestSkipped("Unable to create Unicode filename")
> +
> +        os.chdir(u'B\xe5gfors')
> +        self.assertEndsWith(osutils._mac_getcwd(), u'B\xe5gfors')
> +
> +    def test_getcwd_nonnorm(self):
> +        # Test that _mac_getcwd() will normalize this path
> +        try:
> +            os.mkdir(u'Ba\u030agfors')
> +        except UnicodeError:
> +            raise TestSkipped("Unable to create Unicode filename")
> +
> +        os.chdir(u'Ba\u030agfors')
> +        self.assertEndsWith(osutils._mac_getcwd(), u'B\xe5gfors')
> +

These two could perhaps do with a comment explaining why calling the
_mac_getcwd function is safe on other platforms.  (I think it is, and
it's nice that we can test it everywhere.)

-- 
Martin




More information about the bazaar mailing list