diff options
author | Bob Ippolito <bob@redivi.com> | 2018-02-20 14:32:16 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-20 14:32:16 -0800 |
commit | d713b973cbf27259d8d1dee9ffd1dcda5937565e (patch) | |
tree | 98bc695baae93eb5a2d75df05be7077e4f923f7e | |
parent | ed5a6e6695ca9d8d472fdba25433c96da4064886 (diff) | |
parent | 4366bb9b3952adfd73792cd4fea2b427e88cc43b (diff) | |
download | xattr-d713b973cbf27259d8d1dee9ffd1dcda5937565e.tar.gz |
Merge pull request #66 from novel/test-fsencodings
Make tests independent of user's locale
-rw-r--r-- | xattr/tests/test_xattr.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/xattr/tests/test_xattr.py b/xattr/tests/test_xattr.py index c22efec..cb6ebb9 100644 --- a/xattr/tests/test_xattr.py +++ b/xattr/tests/test_xattr.py @@ -13,7 +13,22 @@ class BaseTestXattr(object): # manual override here. TESTDIR = None - def test_attr(self): + def test_attr_fs_encoding_unicode(self): + # Not using setlocale(LC_ALL, ..) to set locale because + # sys.getfilesystemencoding() implementation falls back + # to user's preferred locale by calling setlocale(LC_ALL, ''). + xattr.compat.fs_encoding = 'UTF-8' + self._test_attr() + + def test_attr_fs_encoding_ascii(self): + xattr.compat.fs_encoding = 'US-ASCII' + if sys.version_info[0] < 3: + with self.assertRaises(UnicodeEncodeError): + self._test_attr() + else: + self._test_attr() + + def _test_attr(self): x = xattr.xattr(self.tempfile) # Solaris 11 and forward contain system attributes (file flags) in |