components/python/xattr/patches/test.patch
changeset 4894 7219201c1b0d
parent 1847 b43426a2f6ba
equal deleted inserted replaced
4893:95c28fe27246 4894:7219201c1b0d
     1 Every file on Solaris 11 and on has two extended attributes, so if we find
     1 Every file on Solaris 11 and on has two extended attributes, so if we find
     2 them, we shouldn't fail.  Also, we don't support extended attributes on
     2 them, we shouldn't fail.  Also, we don't support extended attributes on
     3 symlinks, so just quietly pass that test.
     3 symlinks, so just quietly pass that test.
       
     4 
       
     5 Additionally, fix comparison of lists to dict_keys in Python 3. This has been
       
     6 fixed in newer versions of xattr which will be part of a future update of the
       
     7 userland version of xattr.
     4 
     8 
     5 Merged as of 0.7.6.
     9 Merged as of 0.7.6.
     6 
    10 
     7 diff --git a/xattr/tests/test_xattr.py b/xattr/tests/test_xattr.py
    11 diff --git a/xattr/tests/test_xattr.py b/xattr/tests/test_xattr.py
     8 --- a/xattr/tests/test_xattr.py	Mon Mar  3 10:12:24 2014
    12 --- a/xattr/tests/test_xattr.py	Mon Mar  3 10:12:24 2014
    11  import os
    15  import os
    12 +import sys
    16 +import sys
    13  from unittest import TestCase
    17  from unittest import TestCase
    14  from tempfile import mkdtemp, NamedTemporaryFile
    18  from tempfile import mkdtemp, NamedTemporaryFile
    15  
    19  
    16 @@ -8,10 +9,19 @@
    20 @@ -8,9 +9,18 @@
    17  class BaseTestXattr(object):
    21  class BaseTestXattr(object):
    18      def test_attr(self):
    22      def test_attr(self):
    19          x = xattr.xattr(self.tempfile)
    23          x = xattr.xattr(self.tempfile)
    20 -        self.assertEqual(x.keys(), [])
    24 -        self.assertEqual(x.keys(), [])
    21 -        self.assertEqual(x.list(), [])
    25 -        self.assertEqual(x.list(), [])
    22 -        self.assertEqual(dict(x), {})
    26 -        self.assertEqual(dict(x), {})
    23  
    27 +
    24 +        # Solaris 11 and forward contain system attributes (file flags) in
    28 +        # Solaris 11 and forward contain system attributes (file flags) in
    25 +        # extended attributes present on all files, so cons them up into a
    29 +        # extended attributes present on all files, so cons them up into a
    26 +        # comparison dict.
    30 +        # comparison dict.
    27 +        d = {}
    31 +        d = {}
    28 +        if sys.platform == 'sunos5' and 'SUNWattr_ro' in x:
    32 +        if sys.platform == 'sunos5' and 'SUNWattr_ro' in x:
    29 +            d['SUNWattr_ro'] = x['SUNWattr_ro']
    33 +            d['SUNWattr_ro'] = x['SUNWattr_ro']
    30 +            d['SUNWattr_rw'] = x['SUNWattr_rw']
    34 +            d['SUNWattr_rw'] = x['SUNWattr_rw']
    31 +
    35 +
    32 +        self.assertEqual(x.keys(), d.keys())
    36 +        self.assertEqual(x.keys(), list(d.keys()))
    33 +        self.assertEqual(x.list(), d.keys())
    37 +        self.assertEqual(x.list(), list(d.keys()))
    34 +        self.assertEqual(dict(x), d)
    38 +        self.assertEqual(dict(x), d)
    35 +
    39  
    36          x['user.sopal'] = b'foo'
    40          x['user.sopal'] = b'foo'
    37          x['user.sop.foo'] = b'bar'
    41          x['user.sop.foo'] = b'bar'
    38          x[u'user.\N{SNOWMAN}'] = b'not a snowman'
       
    39 @@ -38,6 +48,9 @@
    42 @@ -38,6 +48,9 @@
    40          self.assertTrue('user.sop.foo' not in x)
    43          self.assertTrue('user.sop.foo' not in x)
    41  
    44  
    42      def test_symlink_attrs(self):
    45      def test_symlink_attrs(self):
    43 +        # Solaris doesn't support extended attributes on symlinks
    46 +        # Solaris doesn't support extended attributes on symlinks