mirror of
https://github.com/python/cpython.git
synced 2025-10-17 04:08:28 +00:00
Issue #23738: Document and test actual keyword parameter names
Also fix signature because os.utime(..., ns=None) is not allowed.
This commit is contained in:
parent
5558d4f2f8
commit
bf19d16950
9 changed files with 73 additions and 31 deletions
|
@ -58,7 +58,7 @@ HAVE_WHEEL_GROUP = sys.platform.startswith('freebsd') and os.getgid() == 0
|
|||
# Tests creating TESTFN
|
||||
class FileTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
if os.path.exists(support.TESTFN):
|
||||
if os.path.lexists(support.TESTFN):
|
||||
os.unlink(support.TESTFN)
|
||||
tearDown = setUp
|
||||
|
||||
|
@ -162,6 +162,19 @@ class FileTests(unittest.TestCase):
|
|||
with open(TESTFN2, 'r') as f:
|
||||
self.assertEqual(f.read(), "1")
|
||||
|
||||
def test_open_keywords(self):
|
||||
f = os.open(path=__file__, flags=os.O_RDONLY, mode=0o777,
|
||||
dir_fd=None)
|
||||
os.close(f)
|
||||
|
||||
def test_symlink_keywords(self):
|
||||
symlink = support.get_attribute(os, "symlink")
|
||||
try:
|
||||
symlink(src='target', dst=support.TESTFN,
|
||||
target_is_directory=False, dir_fd=None)
|
||||
except (NotImplementedError, OSError):
|
||||
pass # No OS support or unprivileged user
|
||||
|
||||
|
||||
# Test attributes on return values from os.*stat* family.
|
||||
class StatAttributeTests(unittest.TestCase):
|
||||
|
@ -2151,6 +2164,14 @@ class TestSendfile(unittest.TestCase):
|
|||
os.sendfile(self.sockno, self.fileno, -1, 4096)
|
||||
self.assertEqual(cm.exception.errno, errno.EINVAL)
|
||||
|
||||
def test_keywords(self):
|
||||
# Keyword arguments should be supported
|
||||
os.sendfile(out=self.sockno, offset=0, count=4096,
|
||||
**{'in': self.fileno})
|
||||
if self.SUPPORT_HEADERS_TRAILERS:
|
||||
os.sendfile(self.sockno, self.fileno, offset=0, count=4096,
|
||||
headers=None, trailers=None, flags=0)
|
||||
|
||||
# --- headers / trailers tests
|
||||
|
||||
@requires_headers_trailers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue