summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_shutil.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-37834: Normalise handling of reparse points on Windows (GH-15231)Steve Dower2019-08-211-3/+66
| | | | | | | | | | bpo-37834: Normalise handling of reparse points on Windows * ntpath.realpath() and nt.stat() will traverse all supported reparse points (previously was mixed) * nt.lstat() will let the OS traverse reparse points that are not name surrogates (previously would not traverse any reparse point) * nt.[l]stat() will only set S_IFLNK for symlinks (previous behaviour) * nt.readlink() will read destinations for symlinks and junction points only bpo-1311: os.path.exists('nul') now returns True on Windows * nt.stat('nul').st_mode is now S_IFCHR (previously was an error)
* bpo-9949: Enable symlink traversal for ntpath.realpath (GH-15287)Steve Dower2019-08-211-5/+1
|
* bpo-37421: Fix test_shutil: don't leak temporary files (GH-14416)Victor Stinner2019-06-261-2/+3
| | | | | | | * Fix typo in supports_file2file_sendfile(); ensure that dst is removed * Fix test_copytree_custom_copy_function(): remove dst tree. Use support.rmtree() rather than shutil.rmtree() to remove temporary directories: support tries harder.
* bpo-36610: shutil.copyfile(): use sendfile() on Linux only (GH-13675)Giampaolo Rodola2019-05-301-3/+3
| | | | ...and avoid using it on Solaris as it can raise EINVAL if offset is equal or bigger than the size of the file
* bpo-24538: Fix bug in shutil involving the copying of xattrs to read-only ↵Olexa Bilaniuk2019-05-101-0/+8
| | | | | | | | files. (PR-13212) Extended attributes can only be set on user-writeable files, but shutil previously first chmod()ed the destination file to the source's permissions and then tried to copy xattrs. This will cause failures if attempting to copy read-only files with xattrs, as occurs with Git clones on Lustre FS.
* bpo-35755: shutil.which() uses os.confstr("CS_PATH") (GH-12858)Victor Stinner2019-04-171-0/+68
| | | | | | | | | | | | | | | | shutil.which() and distutils.spawn.find_executable() now use os.confstr("CS_PATH") if available instead of os.defpath, if the PATH environment variable is not set. Don't use os.confstr("CS_PATH") nor os.defpath if the PATH environment variable is set to an empty string to mimick Unix 'which' command behavior. Changes: * find_executable() now starts by checking for the executable in the current working directly case. Add an explicit "if not path: return None". * Add tests for PATH='' (empty string), PATH=':' and for PATHEXT.
* bpo-35652: shutil.copytree(copy_function=...) erroneously pass DirEntry ↵Giampaolo Rodola2019-02-261-0/+18
| | | | instead of path str (GH-11997)
* Clean up code which checked presence of os.{stat,lstat,chmod} (#11643)Anthony Sottile2019-02-251-4/+0
|
* bpo-35704: Prevent test_shutil fail result when AIX is 32-bit and MAXDATA < ↵Michael Felt2019-02-181-0/+13
| | | | | 0x20000000 (GH-11500) https://bugs.python.org/issue35704
* bpo-18283: Add support for bytes to shutil.which (GH-11818)Cheryl Sabella2019-02-131-4/+17
|
* bpo-20849: add dirs_exist_ok arg to shutil.copytree (patch by Josh Bronson)jab2018-12-281-0/+25
|
* bpo-35458: Fix test_shutil.test_disk_usage() (GH-11111)Victor Stinner2018-12-111-1/+5
| | | | | | | | | | The following test fails if a different process creates or removes a file on the same disk partition between the two lines: usage = shutil.disk_usage(os.path.dirname(__file__)) self.assertEqual(usage, shutil.disk_usage(__file__)) Only test that disk_usage() succeed on a filename, but don't check the result. Add also tests on the fields type (must be int).
* bpo-32557: allow shutil.disk_usage to take a file path on Windows also (GH-9372)Joe Pamer2018-09-251-0/+1
| | | https://bugs.python.org/issue32557
* bpo-34661: Fix test skipping call. (GH-9266)Benjamin Peterson2018-09-131-1/+1
|
* closes bpo-34661: Fix test_shutil if unzip doesn't support -t. (GH-9262)Benjamin Peterson2018-09-131-0/+2
|
* Revert "bpo-33671: Add support.MS_WINDOWS and support.MACOS (GH-7800)" (GH-7919)Victor Stinner2018-06-261-4/+5
| | | This reverts commit 8fbbdf0c3107c3052659e166f73990b466eacbb0.
* bpo-33671: Add support.MS_WINDOWS and support.MACOS (GH-7800)Victor Stinner2018-06-221-5/+4
| | | | | | | | * Add support.MS_WINDOWS: True if Python is running on Microsoft Windows. * Add support.MACOS: True if Python is running on Apple macOS. * Replace support.is_android with support.ANDROID * Replace support.is_jython with support.JYTHON * Cleanup code to initialize unix_shell
* bpo-33671 / shutil.copyfile: use memoryview() with dynamic size on Windows ↵Giampaolo Rodola2018-06-191-7/+81
| | | | | | | | | | (#7681) bpo-33671 * use memoryview() with size == file size on Windows, see https://github.com/python/cpython/pull/7160#discussion_r195405230 * release intermediate (sliced) memoryview immediately * replace "OSX" occurrences with "macOS" * add some unittests for copyfileobj()
* bpo-33671: efficient zero-copy for shutil.copy* functions (Linux, OSX and ↵Giampaolo Rodola2018-06-121-2/+292
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Win) (#7160) * have shutil.copyfileobj use sendfile() if possible * refactoring: use ctx manager * add test with non-regular file obj * emulate case where file size can't be determined * reference _copyfileobj_sendfile directly * add test for offset() at certain position * add test for empty file * add test for non regular file dst * small refactoring * leave copyfileobj() alone in order to not introduce any incompatibility * minor refactoring * remove old test * update docstring * update docstring; rename exception class * detect platforms which only support file to socket zero copy * don't run test on platforms where file-to-file zero copy is not supported * use tempfiles * reset verbosity * add test for smaller chunks * add big file size test * add comment * update doc * update whatsnew doc * update doc * catch Exception * remove unused import * add test case for error on second sendfile() call * turn docstring into comment * add one more test * update comment * add Misc/NEWS entry * get rid of COPY_BUFSIZE; it belongs to another PR * update doc * expose posix._fcopyfile() for OSX * merge from linux branch * merge from linux branch * expose fcopyfile * arg clinic for the win implementation * convert path type to path_t * expose CopyFileW * fix windows tests * release GIL * minor refactoring * update doc * update comment * update docstrings * rename functions * rename test classes * update doc * update doc * update docstrings and comments * avoid do import nt|posix modules if unnecessary * set nt|posix modules to None if not available * micro speedup * update description * add doc note * use better wording in doc * rename function using 'fastcopy' prefix instead of 'zerocopy' * use :ref: in rst doc * change wording in doc * add test to make sure sendfile() doesn't get called aymore in case it doesn't support file to file copies * move CopyFileW in _winapi and actually expose CopyFileExW instead * fix line endings * add tests for mode bits * add docstring * remove test file mode class; let's keep it for later when Istart addressing OSX fcopyfile() specific copies * update doc to reflect new changes * update doc * adjust tests on win * fix argument clinic error * update doc * OSX: expose copyfile(3) instead of fcopyfile(3); also expose flags arg to python * osx / copyfile: use path_t instead of char * do not set dst name in the OSError exception in order to remain consistent with platforms which cannot do that (e.g. linux) * add same file test * add test for same file * have osx copyfile() pre-emptively check if src and dst are the same, otherwise it will return immedialtey and src file content gets deleted * turn PermissionError into appropriate SameFileError * expose ERROR_SHARING_VIOLATION in order to raise more appropriate SameFileError * honour follow_symlinks arg when using CopyFileEx * update Misc/NEWS * expose CreateDirectoryEx mock * change C type * CreateDirectoryExW actual implementation * provide specific makedirs() implementation for win * fix typo * skeleton for SetNamedSecurityInfo * get security info for src path * finally set security attrs * add unit tests * mimick os.makedirs() behavior and raise if dst dir exists * set 2 paths for OSError object * set 2 paths for OSError object * expand windows test * in case of exception on os.sendfile() set filename and filename2 exception attributes * set 2 filenames (src, dst) for OSError in case copyfile() fails on OSX * update doc * do not use CreateDirectoryEx() in copytree() if source dir is a symlink (breaks test_copytree_symlink_dir); instead just create a plain dir and remain consistent with POSIX implementation * use bytearray() and readinto() * use memoryview() with bytearray() * refactoring + introduce a new _fastcopy_binfileobj() fun * remove CopyFileEx and other C wrappers * remove code related to CopyFileEx * Recognize binary files in copyfileobj() ...and use fastest _fastcopy_binfileobj() when possible * set 1MB copy bufsize on win; also add a global _COPY_BUFSIZE variable * use ctx manager for memoryview() * update doc * remove outdated doc * remove last CopyFileEx remnants * OSX - use fcopyfile(3) instead of copyfile(3) ...as an extra safety measure: in case src/dst are "exotic" files (non regular or living on a network fs etc.) we better fail on open() instead of copyfile(3) as we're not quite sure what's gonna happen in that case. * update doc
* bpo-32964: Reuse a testing implementation of the path protocol in tests. (#5930)Serhiy Storchaka2018-03-021-9/+2
|
* bpo-28759: Skip some tests on PermissionError raised by Android (GH-4350)xdegaye2017-11-121-7/+13
| | | | | | Access to mkfifo(), mknod() and hard link creation is controled by SELinux on Android. Also remove test.support.android_not_root.
* bpo-28564: Use os.scandir() in shutil.rmtree(). (#4085)Serhiy Storchaka2017-11-041-1/+1
| | | | This speeds up it to 20-40%.
* Make test_shutil test_disk_usage not depend on the cwd fs (#2597)Gregory P. Smith2017-07-071-1/+1
| | | Make test_shutil test_disk_usage not depend on the current working directory's filesystem.
* bpo-30218: support path-like objects in shutil.unpack_archive() (GH-1367)Jelle Zijlstra2017-05-051-4/+17
| | | Thanks to Jelle Zijlstra for the patch.
* bpo-29919: Remove unused imports found by pyflakes (#137)Victor Stinner2017-03-271-3/+1
| | | Make also minor PEP8 coding style fixes on modified imports.
* Remove unused imports.Serhiy Storchaka2016-12-161-1/+0
|
* Issue #14061: Misc fixes and cleanups in archiving code in shutil.Serhiy Storchaka2016-12-161-51/+44
|\ | | | | | | | | | | Imporoved the documentation and tests for make_archive() and unpack_archive(). Improved error handling when corresponding compress module is not available. Brake circular dependency between shutil and tarfile modules.
| * Issue #14061: Misc fixes and cleanups in archiving code in shutil.Serhiy Storchaka2016-12-161-51/+44
| | | | | | | | | | | | Imporoved the documentation and tests for make_archive() and unpack_archive(). Improved error handling when corresponding compress module is not available. Brake circular dependency between shutil and tarfile modules.
* | Issue #28759: Fix the tests that fail with PermissionError when run asXavier de Gaye2016-12-131-1/+5
| | | | | | | | a non-root user on Android where access rights are controled by SELinux MAC.
* | Issue #28662: Catch PermissionError in tests when spawning a non existent ↵Xavier de Gaye2016-11-141-1/+2
| | | | | | | | program
* | Issue #28488: shutil.make_archive() no longer adds entry "./" to ZIP archive.Serhiy Storchaka2016-10-231-0/+13
|\ \ | |/
| * Issue #28488: shutil.make_archive() no longer adds entry "./" to ZIP archive.Serhiy Storchaka2016-10-231-0/+13
| |
* | Fixes tests broken by issue #27781.Steve Dower2016-09-081-3/+1
| |
* | Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Raymond Hettinger2016-08-301-2/+2
|/
* Issue #27626: Spelling fixes in docs, comments and internal namesMartin Panter2016-07-281-1/+1
| | | | Based on patch by Ville Skyttä.
* Issue #26801: shutil.get_terminal_size() now handles the case of stdout isSerhiy Storchaka2016-04-241-0/+29
| | | | reopened on Windows. Added tests for fallbacks.
* Fix shutil.get_terminal_size() error handlingVictor Stinner2016-04-191-0/+2
| | | | | | | | Issue #26801: Fix error handling in shutil.get_terminal_size(), catch AttributeError instead of NameError. Patch written by Emanuel Barry. test_shutil: skip the functional test using "stty size" command if os.get_terminal_size() is missing.
* Issue #25624: ZipFile now always writes a ZIP_STORED header for directorySerhiy Storchaka2015-11-221-0/+23
|\ | | | | | | entries. Patch by Dingyuan Wang.
| * Issue #25624: ZipFile now always writes a ZIP_STORED header for directorySerhiy Storchaka2015-11-221-0/+23
| | | | | | | | entries. Patch by Dingyuan Wang.
* | Issue #25686: test_shutil no longer uses the distutils package for searchingSerhiy Storchaka2015-11-211-9/+7
|\ \ | |/ | | | | and running external archivers.
| * Issue #25686: test_shutil no longer uses the distutils package for searchingSerhiy Storchaka2015-11-211-9/+7
| | | | | | | | and running external archivers.
* | Issue #25607: Restore old distutils logging threshold after running tests thatSerhiy Storchaka2015-11-121-1/+1
|\ \ | |/ | | | | parse command line arguments.
| * Issue #25607: Restore old distutils logging threshold after running tests thatSerhiy Storchaka2015-11-121-1/+1
| | | | | | | | parse command line arguments.
* | Fixed tests for shutil.make_archive() with relative base_name in the case whenSerhiy Storchaka2015-09-081-2/+2
|\ \ | |/ | | | | the path of the directory for temporary files contains symlinks.
| * Fixed tests for shutil.make_archive() with relative base_name in the case whenSerhiy Storchaka2015-09-081-2/+2
| | | | | | | | the path of the directory for temporary files contains symlinks.
* | Issue #24982: shutil.make_archive() with the "zip" format now adds entriesSerhiy Storchaka2015-09-081-6/+31
|\ \ | |/ | | | | | | for directories (including empty directories) in ZIP file. Added test for comparing shutil.make_archive() with the "zip" command.
| * Issue #24982: shutil.make_archive() with the "zip" format now adds entriesSerhiy Storchaka2015-09-081-6/+31
| | | | | | | | | | for directories (including empty directories) in ZIP file. Added test for comparing shutil.make_archive() with the "zip" command.
* | Issue #25018: Fixed testing shutil.make_archive() with relative base_name onSerhiy Storchaka2015-09-071-9/+19
|\ \ | |/ | | | | | | Windows. The test now makes sense on non-Windows. Added similar test for zip format.
| * Issue #25018: Fixed testing shutil.make_archive() with relative base_name onSerhiy Storchaka2015-09-071-9/+19
| | | | | | | | | | Windows. The test now makes sense on non-Windows. Added similar test for zip format.
* | Explicitly test archive name in shutil.make_archive() tests to expose failureSerhiy Storchaka2015-09-071-11/+11
|\ \ | |/ | | | | details in issue25018.