Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(11)

Unified Diff: Lib/test/test_posix.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_platform.py ('k') | Lib/test/test_pydoc.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_posix.py Tue Jul 26 09:37:46 2011 +0300
+++ b/Lib/test/test_posix.py Mon Jul 25 09:47:18 2011 -0400
@@ -16,7 +16,6 @@
import unittest
import warnings
-_DUMMY_SYMLINK = '%s/dummy-symlink' % os.getenv('TMPDIR', '/tmp')
class PosixTester(unittest.TestCase):
@@ -24,15 +23,13 @@
# create empty file
fp = open(support.TESTFN, 'w+')
fp.close()
- self.teardown_files = [ support.TESTFN ]
self._warnings_manager = support.check_warnings()
self._warnings_manager.__enter__()
warnings.filterwarnings('ignore', '.* potential security risk .*',
RuntimeWarning)
def tearDown(self):
- for teardown_file in self.teardown_files:
- support.unlink(teardown_file)
+ support.unlink(support.TESTFN)
self._warnings_manager.__exit__(None, None, None)
def testNoArgFunctions(self):
@@ -410,7 +407,7 @@
self.assertRaises(OSError, posix.chown, support.TESTFN, -1, -1)
# re-create the file
- support.create_empty_file(support.TESTFN)
+ open(support.TESTFN, 'w').close()
self._test_all_chown_common(posix.chown, support.TESTFN)
@unittest.skipUnless(hasattr(posix, 'fchown'), "test needs os.fchown()")
@@ -429,7 +426,7 @@
def test_lchown(self):
os.unlink(support.TESTFN)
# create a symlink
- os.symlink(_DUMMY_SYMLINK, support.TESTFN)
+ os.symlink('/tmp/dummy-symlink-target', support.TESTFN)
self._test_all_chown_common(posix.lchown, support.TESTFN)
def test_chdir(self):
@@ -514,49 +511,17 @@
posix.utime(support.TESTFN, (int(now), int(now)))
posix.utime(support.TESTFN, (now, now))
- def _test_chflags_regular_file(self, chflags_func, target_file):
- st = os.stat(target_file)
- self.assertTrue(hasattr(st, 'st_flags'))
- chflags_func(target_file, st.st_flags | stat.UF_IMMUTABLE)
- try:
- new_st = os.stat(target_file)
- self.assertEqual(st.st_flags | stat.UF_IMMUTABLE, new_st.st_flags)
- try:
- fd = open(target_file, 'w+')
- except IOError as e:
- self.assertEqual(e.errno, errno.EPERM)
- finally:
- posix.chflags(target_file, st.st_flags)
+ def test_chflags(self):
+ if hasattr(posix, 'chflags'):
+ st = os.stat(support.TESTFN)
+ if hasattr(st, 'st_flags'):
+ posix.chflags(support.TESTFN, st.st_flags)
- @unittest.skipUnless(hasattr(posix, 'chflags'), 'test needs os.chflags()')
- def test_chflags(self):
- self._test_chflags_regular_file(posix.chflags, support.TESTFN)
-
- @unittest.skipUnless(hasattr(posix, 'lchflags'), 'test needs os.lchflags()')
- def test_lchflags_regular_file(self):
- self._test_chflags_regular_file(posix.lchflags, support.TESTFN)
-
- @unittest.skipUnless(hasattr(posix, 'lchflags'), 'test needs os.lchflags()')
- def test_lchflags_symlink(self):
- testfn_st = os.stat(support.TESTFN)
-
- self.assertTrue(hasattr(testfn_st, 'st_flags'))
-
- os.symlink(support.TESTFN, _DUMMY_SYMLINK)
- self.teardown_files.append(_DUMMY_SYMLINK)
- dummy_symlink_st = os.lstat(_DUMMY_SYMLINK)
-
- posix.lchflags(_DUMMY_SYMLINK,
- dummy_symlink_st.st_flags | stat.UF_IMMUTABLE)
- try:
- new_testfn_st = os.stat(support.TESTFN)
- new_dummy_symlink_st = os.lstat(_DUMMY_SYMLINK)
-
- self.assertEqual(testfn_st.st_flags, new_testfn_st.st_flags)
- self.assertEqual(dummy_symlink_st.st_flags | stat.UF_IMMUTABLE,
- new_dummy_symlink_st.st_flags)
- finally:
- posix.lchflags(_DUMMY_SYMLINK, dummy_symlink_st.st_flags)
+ def test_lchflags(self):
+ if hasattr(posix, 'lchflags'):
+ st = os.stat(support.TESTFN)
+ if hasattr(st, 'st_flags'):
+ posix.lchflags(support.TESTFN, st.st_flags)
def test_environ(self):
if os.name == "nt":
@@ -661,7 +626,7 @@
@unittest.skipUnless(hasattr(posix, 'fchownat'), "test needs posix.fchownat()")
def test_fchownat(self):
support.unlink(support.TESTFN)
- support.create_empty_file(support.TESTFN)
+ open(support.TESTFN, 'w').close()
f = posix.open(posix.getcwd(), posix.O_RDONLY)
try:
@@ -766,7 +731,7 @@
@unittest.skipUnless(hasattr(posix, 'renameat'), "test needs posix.renameat()")
def test_renameat(self):
support.unlink(support.TESTFN)
- support.create_empty_file(support.TESTFN + 'ren')
+ open(support.TESTFN + 'ren', 'w').close()
f = posix.open(posix.getcwd(), posix.O_RDONLY)
try:
posix.renameat(f, support.TESTFN + 'ren', f, support.TESTFN)
@@ -791,7 +756,7 @@
@unittest.skipUnless(hasattr(posix, 'unlinkat'), "test needs posix.unlinkat()")
def test_unlinkat(self):
f = posix.open(posix.getcwd(), posix.O_RDONLY)
- support.create_empty_file(support.TESTFN + 'del')
+ open(support.TESTFN + 'del', 'w').close()
posix.stat(support.TESTFN + 'del') # should not throw exception
try:
posix.unlinkat(f, support.TESTFN + 'del')
« no previous file with comments | « Lib/test/test_platform.py ('k') | Lib/test/test_pydoc.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+