summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-12-31 03:30:26 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-12-31 03:30:26 (GMT)
commit68dbebc8e8b7d7cbde146612e22ddcab0a03356a (patch)
tree6a18742cced56bdb1adfdab3412626087d4ccf09 /Lib
parent9207804bdb8492d68455e7a950e70e87e6984232 (diff)
downloadcpython-68dbebc8e8b7d7cbde146612e22ddcab0a03356a.zip
cpython-68dbebc8e8b7d7cbde146612e22ddcab0a03356a.tar.gz
cpython-68dbebc8e8b7d7cbde146612e22ddcab0a03356a.tar.bz2
Merged revisions 77167 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r77167 | benjamin.peterson | 2009-12-30 21:11:23 -0600 (Wed, 30 Dec 2009) | 61 lines Merged revisions 76847,76851,76869,76882,76891-76892,76924,77007,77070,77092,77096,77120,77126,77155 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r76847 | benjamin.peterson | 2009-12-14 21:25:27 -0600 (Mon, 14 Dec 2009) | 1 line adverb ........ r76851 | benjamin.peterson | 2009-12-15 21:28:52 -0600 (Tue, 15 Dec 2009) | 1 line remove lib2to3 resource ........ r76869 | vinay.sajip | 2009-12-17 08:52:00 -0600 (Thu, 17 Dec 2009) | 1 line Issue #7529: logging: Minor correction to documentation. ........ r76882 | georg.brandl | 2009-12-19 11:30:28 -0600 (Sat, 19 Dec 2009) | 1 line #7527: use standard versionadded tags. ........ r76891 | georg.brandl | 2009-12-19 12:16:31 -0600 (Sat, 19 Dec 2009) | 1 line #7479: add note about function availability on Unices. ........ r76892 | georg.brandl | 2009-12-19 12:20:18 -0600 (Sat, 19 Dec 2009) | 1 line #7480: remove tautology. ........ r76924 | georg.brandl | 2009-12-20 08:28:05 -0600 (Sun, 20 Dec 2009) | 1 line Small indentation fix. ........ r77007 | gregory.p.smith | 2009-12-23 03:31:11 -0600 (Wed, 23 Dec 2009) | 3 lines Fix possible integer overflow in lchown and fchown functions. For issue1747858. ........ r77070 | amaury.forgeotdarc | 2009-12-27 14:06:44 -0600 (Sun, 27 Dec 2009) | 2 lines Fix a typo in comment ........ r77092 | georg.brandl | 2009-12-28 02:48:24 -0600 (Mon, 28 Dec 2009) | 1 line #7404: remove reference to non-existing example files. ........ r77096 | benjamin.peterson | 2009-12-28 14:51:17 -0600 (Mon, 28 Dec 2009) | 1 line document new fix_callable behavior ........ r77120 | georg.brandl | 2009-12-29 15:09:17 -0600 (Tue, 29 Dec 2009) | 1 line #7595: fix typo in argument default constant. ........ r77126 | amaury.forgeotdarc | 2009-12-29 17:06:17 -0600 (Tue, 29 Dec 2009) | 2 lines #7579: Add docstrings to the msvcrt module ........ r77155 | georg.brandl | 2009-12-30 13:03:00 -0600 (Wed, 30 Dec 2009) | 1 line We only support Windows NT derivatives now. ........ ................
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/test/regrtest.py2
-rw-r--r--Lib/test/test_posix.py74
2 files changed, 48 insertions, 28 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index c2677d2..c985c50 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -105,8 +105,6 @@ resources to test. Currently only the following are defined:
curses - Tests that use curses and will modify the terminal's
state and output modes.
- lib2to3 - Run the tests for 2to3 (They take a while.)
-
largefile - It is okay to run some test that may create huge
files. These tests can take a long time and may
consume >2GB of disk space temporarily.
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 2047e52..78f7592 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -131,32 +131,54 @@ class PosixTester(unittest.TestCase):
if hasattr(posix, 'stat'):
self.assertTrue(posix.stat(support.TESTFN))
- if hasattr(posix, 'chown'):
- def test_chown(self):
- # raise an OSError if the file does not exist
- os.unlink(support.TESTFN)
- self.assertRaises(OSError, posix.chown, support.TESTFN, -1, -1)
-
- # re-create the file
- open(support.TESTFN, 'w').close()
- if os.getuid() == 0:
- try:
- # Many linux distros have a nfsnobody user as MAX_UID-2
- # that makes a good test case for signedness issues.
- # http://bugs.python.org/issue1747858
- # This part of the test only runs when run as root.
- # Only scary people run their tests as root.
- ent = pwd.getpwnam('nfsnobody')
- posix.chown(support.TESTFN, ent.pw_uid, ent.pw_gid)
- except KeyError:
- pass
- else:
- # non-root cannot chown to root, raises OSError
- self.assertRaises(OSError, posix.chown,
- support.TESTFN, 0, 0)
-
- # test a successful chown call
- posix.chown(support.TESTFN, os.getuid(), os.getgid())
+ def _test_all_chown_common(self, chown_func, first_param):
+ """Common code for chown, fchown and lchown tests."""
+ if os.getuid() == 0:
+ try:
+ # Many linux distros have a nfsnobody user as MAX_UID-2
+ # that makes a good test case for signedness issues.
+ # http://bugs.python.org/issue1747858
+ # This part of the test only runs when run as root.
+ # Only scary people run their tests as root.
+ ent = pwd.getpwnam('nfsnobody')
+ chown_func(first_param, ent.pw_uid, ent.pw_gid)
+ except KeyError:
+ pass
+ else:
+ # non-root cannot chown to root, raises OSError
+ self.assertRaises(OSError, chown_func,
+ first_param, 0, 0)
+ # test a successful chown call
+ chown_func(first_param, os.getuid(), os.getgid())
+
+ @unittest.skipUnless(hasattr(posix, 'chown'), "test needs os.chown()")
+ def test_chown(self):
+ # raise an OSError if the file does not exist
+ os.unlink(support.TESTFN)
+ self.assertRaises(OSError, posix.chown, support.TESTFN, -1, -1)
+
+ # re-create the file
+ open(support.TESTFN, 'w').close()
+ self._test_all_chown_common(posix.chown, support.TESTFN)
+
+ @unittest.skipUnless(hasattr(posix, 'fchown'), "test needs os.fchown()")
+ def test_fchown(self):
+ os.unlink(support.TESTFN)
+
+ # re-create the file
+ test_file = open(support.TESTFN, 'w')
+ try:
+ fd = test_file.fileno()
+ self._test_all_chown_common(posix.fchown, fd)
+ finally:
+ test_file.close()
+
+ @unittest.skipUnless(hasattr(posix, 'lchown'), "test needs os.lchown()")
+ def test_lchown(self):
+ os.unlink(support.TESTFN)
+ # create a symlink
+ os.symlink('/tmp/dummy-symlink-target', support.TESTFN)
+ self._test_all_chown_common(posix.lchown, support.TESTFN)
def test_chdir(self):
if hasattr(posix, 'chdir'):