summaryrefslogtreecommitdiff
path: root/Lib/test/test_posix.py
diff options
context:
space:
mode:
authorFacundo Batista <facundobatista@gmail.com>2008-06-22 13:36:20 +0000
committerFacundo Batista <facundobatista@gmail.com>2008-06-22 13:36:20 +0000
commit5596b0cfc275a649f17a97c881d094a949adad6d (patch)
tree399842aa82a490adc495887f2683833de625af99 /Lib/test/test_posix.py
parent0ba92b24b797c00038b9e2c50d132ffdcdd38959 (diff)
downloadcpython-git-5596b0cfc275a649f17a97c881d094a949adad6d.tar.gz
Issue #2722. Now the char buffer to support the path string has
not fixed length, it mallocs memory if needed. As a result, we don't have a maximum for the getcwd() method.
Diffstat (limited to 'Lib/test/test_posix.py')
-rw-r--r--Lib/test/test_posix.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 179864ac08..188f4631ac 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -10,6 +10,7 @@ except ImportError:
import time
import os
import pwd
+import shutil
import unittest
import warnings
warnings.filterwarnings('ignore', '.* potential security risk .*',
@@ -231,6 +232,38 @@ class PosixTester(unittest.TestCase):
if hasattr(st, 'st_flags'):
posix.lchflags(test_support.TESTFN, st.st_flags)
+ def test_getcwd_long_pathnames(self):
+ if hasattr(posix, 'getcwd'):
+ dirname = 'getcwd-test-directory-0123456789abcdef-01234567890abcdef'
+ curdir = os.getcwd()
+ base_path = os.path.abspath(test_support.TESTFN) + '.getcwd'
+
+ try:
+ os.mkdir(base_path)
+ os.chdir(base_path)
+
+ def _create_and_do_getcwd(dirname, current_path_length = 0):
+ try:
+ os.mkdir(dirname)
+ except:
+ raise test_support.TestSkipped, "mkdir cannot create directory sufficiently deep for getcwd test"
+
+ os.chdir(dirname)
+ try:
+ os.getcwd()
+ if current_path_length < 1027:
+ _create_and_do_getcwd(dirname, current_path_length + len(dirname) + 1)
+ finally:
+ os.chdir('..')
+ os.rmdir(dirname)
+
+ _create_and_do_getcwd(dirname)
+
+ finally:
+ shutil.rmtree(base_path)
+ os.chdir(curdir)
+
+
def test_main():
test_support.run_unittest(PosixTester)