summaryrefslogtreecommitdiff
path: root/xattr/tests/test_xattr.py
diff options
context:
space:
mode:
Diffstat (limited to 'xattr/tests/test_xattr.py')
-rw-r--r--xattr/tests/test_xattr.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/xattr/tests/test_xattr.py b/xattr/tests/test_xattr.py
index 3470013..0124fef 100644
--- a/xattr/tests/test_xattr.py
+++ b/xattr/tests/test_xattr.py
@@ -1,16 +1,17 @@
import os
from unittest import TestCase
-from tempfile import mkstemp, mkdtemp
+from tempfile import mkdtemp, NamedTemporaryFile
+from os import tempnam
import xattr
class TestFile(TestCase):
def setUp(self):
- self.tempfh, self.tempfile = mkstemp()
+ self.tempfile = NamedTemporaryFile()
+ self.tempfilename = self.tempfile.name
def tearDown(self):
- os.close(self.tempfh)
- os.unlink(self.tempfile)
+ self.tempfile.close()
def testAttr(self):
x = xattr.xattr(self.tempfile)
@@ -33,10 +34,22 @@ class TestFile(TestCase):
x = xattr.xattr(self.tempfile)
self.assertTrue('user.sop.foo' not in x)
+ def testSymlinkAttrs(self):
+ symlinkPath = tempnam()
+ os.symlink(self.tempfilename, symlinkPath)
+ try:
+ symlink = xattr.xattr(symlinkPath, options=xattr.XATTR_NOFOLLOW)
+ realfile = xattr.xattr(self.tempfilename)
+ symlink['user.islink'] = 'true'
+ self.assertEqual(dict(realfile), {})
+ self.assertEqual(symlink['user.islink'], 'true')
+ finally:
+ os.remove(symlinkPath)
class TestDir(TestFile):
def setUp(self):
self.tempfile = mkdtemp()
+ self.tempfilename = self.tempfile
def tearDown(self):
os.rmdir(self.tempfile)