Commit Graph

356 Commits

Author SHA1 Message Date
Victor Stinner e12e7aa3fd Issue #15745: Rewrite os.utime() tests in test_os
* Don't use the timestamp of an existing file anymore, only use fixed
  timestamp
* Enhance the code checking the resolution of the filesystem timestamps.
* Check timestamps with a resolution of 1 microsecond instead of 1 millisecond
* When os.utime() uses the current system clock, tolerate a delta of 20 ms.
  Before some os.utime() tolerated a different of 10 seconds.
* Merge duplicated tests and simplify the code
2015-06-12 21:58:00 +02:00
Victor Stinner cf05970307 Remove unused import on test_os 2015-06-12 21:57:50 +02:00
Victor Stinner 47aacc8f69 Issue #15745: Rewrite os.utime() tests in test_os
* Don't use the timestamp of an existing file anymore, only use fixed
  timestamp
* Enhance the code checking the resolution of the filesystem timestamps.
* Check timestamps with a resolution of 1 microsecond instead of 1 millisecond
* When os.utime() uses the current system clock, tolerate a delta of 20 ms.
  Before some os.utime() tolerated a different of 10 seconds.
* Merge duplicated tests and simplify the code
2015-06-12 17:26:23 +02:00
Berker Peksag ce643913a9 Issue #9517: Move script_helper to the support package.
Patch by Christie Wilson.
2015-05-06 06:33:17 +03:00
Victor Stinner 9eb57c5fa5 Issue #22181: The availability of the getrandom() is now checked in configure,
and stored in pyconfig.h as the new HAVE_GETRANDOM_SYSCALL define.

Fix os.urandom() tests using file descriptors if os.urandom() uses getrandom().
2015-03-19 22:21:49 +01:00
Victor Stinner ebaa81f3b1 Merge 3.4 (test_os) 2015-03-12 10:32:20 +01:00
Victor Stinner 0561c53d78 Issue #23605: Refactor os.walk() tests to also run them on os.fwalk() 2015-03-12 10:28:24 +01:00
Steve Dower d5a0be6fc0 Suppress assert dialogs in test_os 2015-03-07 21:25:54 -08:00
Victor Stinner 6036e4431d Issue #22524: New os.scandir() function, part of the PEP 471: "os.scandir()
function -- a better and faster directory iterator". Patch written by Ben
Hoyt.
2015-03-08 01:58:04 +01:00
Serhiy Storchaka a9e00d13cd Issue #20069: Fixed test_os on Solaris: error message is platform depended. 2015-02-16 08:35:18 +02:00
R David Murray f2ad173eaf #20069: Add tests for os.chown.
Patch by Vajrasky Kok.
2014-12-25 18:36:56 -05:00
Victor Stinner fe02e39029 Issue #22585: On OpenBSD 5.6 and newer, os.urandom() now calls getentropy(),
instead of reading /dev/urandom, to get pseudo-random bytes.
2014-12-21 01:16:38 +01:00
Victor Stinner 4d6a3d6c01 Issue #22585: On OpenBSD 5.6 and newer, os.urandom() now calls getentropy(),
instead of reading /dev/urandom, to get pseudo-random bytes.
2014-12-21 01:16:38 +01:00
Serhiy Storchaka 65ee4674e2 Issue #22777: Test pickling with all protocols. 2014-12-15 14:06:02 +02:00
Serhiy Storchaka bad1257c96 Issue #22777: Test pickling with all protocols. 2014-12-15 14:03:42 +02:00
Yury Selivanov 97e2e06af8 os: Include posix functions in os.__all__. Closes issue #18554.
Patch by Ronald Oussoren.
2014-09-26 12:33:06 -04:00
Victor Stinner 1db9e7bb19 Issue #22054: Add os.get_blocking() and os.set_blocking() functions to get and
set the blocking mode of a file descriptor (False if the O_NONBLOCK flag is
set, True otherwise). These functions are not available on Windows.
2014-07-29 22:32:47 +02:00
Victor Stinner 5c6e6fc57e Issue #21932: Skip test_os.test_large_read() on 32-bit system 2014-07-12 11:03:53 +02:00
Victor Stinner 6e1ccfe872 Issue #21932: Ooops, os.read(fd, size) allocates a buffer of size bytes, even
if the file is much smaller. Add @bigmemtest decorator to the new
test_large_read().
2014-07-11 17:35:06 +02:00
Victor Stinner b28ed92dd0 Issue #21932: os.read() now uses a :c:func:`Py_ssize_t` type instead of
:c:type:`int` for the size to support reading more than 2 GB at once. On
Windows, the size is truncted to INT_MAX. As any call to os.read(), the OS
may read less bytes than the number of requested bytes.
2014-07-11 17:04:41 +02:00
Zachary Ware 63f277b694 Issue #21741: Add st_file_attributes to os.stat_result on Windows.
Patch by Ben Hoyt.
2014-06-19 09:46:37 -05:00
Ned Deily ab6b9f8a5b Issue #22585: make URandomFDTests test case actually run 2015-03-17 04:30:08 -07:00
Tim Golden 0321cf2550 Issue18314 Allow unlink to remove junctions. Includes support for creating junctions. Patch by Kim Gräsman 2014-05-05 19:46:17 +01:00
Tim Golden fbf963c064 Backed out changeset: 17df50df62c7 2014-04-27 18:35:36 +01:00
Tim Golden 4675d798bf Issue #18314 os.unlink will now remove junction points on Windows. Patch by Kim Gräsman. 2014-04-27 18:00:10 +01:00
Antoine Pitrou e472aeafc3 Issue #21207: Detect when the os.urandom cached fd has been closed or replaced, and open it anew. 2014-04-26 14:33:03 +02:00
Benjamin Peterson 9dc203fff9 merge 3.3 (#21082) 2014-04-01 19:18:48 -04:00
Benjamin Peterson 4717e2112b merge 3.2 (#21082) 2014-04-01 19:17:57 -04:00
Benjamin Peterson ee5f1c13d1 remove directory mode check from makedirs (closes #21082) 2014-04-01 19:13:18 -04:00
Victor Stinner 149e540adf (Merge 3.3) Issue #20113: os.readv() and os.writev() now raise an OSError
exception on error instead of returning -1.
2014-01-08 15:26:12 +01:00
Victor Stinner 57ddf78b6b Issue #20113: os.readv() and os.writev() now raise an OSError exception on
error instead of returning -1.
2014-01-08 15:21:28 +01:00
Zachary Ware 101d9e7250 Issue 19572: More silently skipped tests explicitly skipped. 2013-12-08 00:44:27 -06:00
Zachary Ware 9fe6d86709 Issue 19572: More silently skipped tests explicitly skipped. 2013-12-08 00:20:35 -06:00
Serhiy Storchaka 43767638a9 Issue #18702: All skipped tests now reported as skipped. 2013-11-03 21:31:38 +02:00
Serhiy Storchaka 7908068627 Issue #18702: All skipped tests now reported as skipped. 2013-11-03 21:31:18 +02:00
Tim Golden 1cc3540669 Correct whitespace in test_os 2013-10-25 21:26:06 +01:00
Tim Golden 781bbebacb Issue13234 Allow listdir to handle extended paths on Windows (Patch by Santoso Wijaya) 2013-10-25 20:24:06 +01:00
Victor Stinner 370cb25307 test_os: report tests as skipped when os.statvfs() fails with ENOSYS 2013-10-12 01:33:54 +02:00
Christian Heimes 2582762b1b Issue #19209: Remove import of copyreg from the os module to speed up
interpreter startup. stat_result and statvfs_result are now hard-coded to
reside in the os module.
The patch is based on Victor Stinner's patch.
2013-10-12 01:27:08 +02:00
Victor Stinner 4f7a36f84f Issue #18904: test_os and test_socket use unittest.skipIf() to check if fcntl
module is present (to record skipped tests)
2013-09-08 14:14:38 +02:00
Victor Stinner 7ba6b0f943 Issue #18904: Improve os.get/set_inheritable() tests 2013-09-08 11:47:54 +02:00
Victor Stinner daf455554b Issue #18571: Implementation of the PEP 446: file descriptors and file handles
are now created non-inheritable; add functions os.get/set_inheritable(),
os.get/set_handle_inheritable() and socket.socket.get/set_inheritable().
2013-08-28 00:53:59 +02:00
Antoine Pitrou f5e30d8b54 Issue #18756: make test_urandom_failure more robust by executing its code in a subprocess 2013-08-24 20:52:45 +02:00
Antoine Pitrou eba25bafc7 Issue #18756: make test_urandom_failure more robust by executing its code in a subprocess 2013-08-24 20:52:27 +02:00
Victor Stinner a93c6db68b (Merge 3.3) Close #17702: On error, os.environb now removes suppress the except
context when raising a new KeyError with the original key.
2013-08-23 19:23:42 +02:00
Victor Stinner 0c2dd0c0a9 Close #17702: On error, os.environb now removes suppress the except context
when raising a new KeyError with the original key.
2013-08-23 19:19:15 +02:00
Antoine Pitrou 95b21460ee Issue #18756: Improve error reporting in os.urandom() when the failure is due to something else than /dev/urandom not existing. 2013-08-16 20:49:32 +02:00
Antoine Pitrou ec34ab5010 Issue #18756: Improve error reporting in os.urandom() when the failure is due to something else than /dev/urandom not existing. 2013-08-16 20:44:38 +02:00
Victor Stinner f0e521036c (Merge 3.3) Issue #18296: Try to fix TestSendfile.test_trailers() of test_os on FreeBSD 2013-08-15 11:57:19 +02:00
Victor Stinner 5e4d6398a1 Issue #18296: Try to fix TestSendfile.test_trailers() of test_os on FreeBSD 2013-08-15 11:57:02 +02:00
Terry Jan Reedy 4a0b6f70f6 Issue #15301: skip new test method so Windows builtbots stop failing. 2013-08-10 20:58:59 -04:00
Larry Hastings a27b83ad2d Issue #15301: Parsing fd, uid, and gid parameters for builtins
in Modules/posixmodule.c is now far more robust.
2013-08-08 00:19:50 -07:00
Jason R. Coombs b501b565c6 Use simple call to os.symlink for broken link (intended for previous commit) 2013-05-27 23:52:43 -04:00
Jason R. Coombs 3a09286790 Issue #13772: Restored directory detection of targets in `os.symlink` on Windows, which was temporarily removed in Python 3.2.3 due to an incomplete implementation. The implementation now works even if the symlink is created in a location other than the current directory. 2013-05-27 23:21:28 -04:00
Jason R. Coombs fb1141cd55 Merge with 3.3 2013-05-27 23:53:02 -04:00
Jason R. Coombs 8f1a8e32b1 Merge with 3.3 2013-05-27 23:26:36 -04:00
Charles-Francois Natali 44feda3cd0 Issue #17914: Add os.cpu_count(). Patch by Yogesh Chaudhari, based on an
initial patch by Trent Nelson.
2013-05-20 14:40:46 +02:00
Victor Stinner 672559fc4f (Merge 3.3) Issue #17702: use assertRaises() for the unit test 2013-04-14 16:43:38 +02:00
Victor Stinner 839e5eafcb Issue #17702: use assertRaises() for the unit test 2013-04-14 16:43:03 +02:00
Victor Stinner 43aa0d07e2 (Merge 3.3) Close #17702: os.environ now raises KeyError with the original
environment variable name (str on UNIX), instead of using the encoded name
(bytes on UNIX).
2013-04-14 16:38:35 +02:00
Victor Stinner 6d10139d70 Close #17702: os.environ now raises KeyError with the original environment
variable name (str on UNIX), instead of using the encoded name (bytes on UNIX).
2013-04-14 16:35:04 +02:00
Stefan Krah a8e59feeb5 Merge 3.3. 2013-01-17 15:34:50 +01:00
Stefan Krah ebee49a487 Issue #14110: Fix test failures on FreeBSD if the user is in the wheel group. 2013-01-17 15:31:00 +01:00
Victor Stinner 67eb8df902 (Merge 3.3) Issue #9644: Add a test on os.statvfs() for the PEP 383 2013-01-01 23:17:22 +01:00
Victor Stinner a25be07103 Issue #9644: Add a test on os.statvfs() for the PEP 383 2013-01-01 23:11:21 +01:00
Victor Stinner e4110dc11f Issue #9644: Fix the encoding used by os.statvfs(): use the filesystem encoding
with the surrogateescape error handler, instead of UTF-8 in strict mode.
2013-01-01 23:05:55 +01:00
Andrew Svetlov 914ab8420e Add test coverage for os.removedirs (#16775) 2012-12-25 12:21:49 +02:00
Andrew Svetlov 34dcdee177 Add test coverage for os.removedirs (#16775) 2012-12-25 12:20:39 +02:00
Andrew Svetlov 405faed511 Add test coverage for os.removedirs (#16775) 2012-12-25 12:18:09 +02:00
Andrew Svetlov 8b33dd8e54 Use OESeeror instead of os.error (#16720)
Patch by Serhiy Storchaka.
2012-12-24 19:58:48 +02:00
Andrew Svetlov 2606a6f197 Issue #16719: Get rid of WindowsError. Use OSError instead
Patch by Serhiy Storchaka.
2012-12-19 14:33:35 +02:00
Andrew Svetlov a191959849 Issue #16714: use 'raise' exceptions, don't 'throw'.
Patch by Serhiy Storchaka.
2012-12-18 21:27:16 +02:00
Andrew Svetlov 5b89840d9c Issue #16714: use 'raise' exceptions, don't 'throw'.
Patch by Serhiy Storchaka.
2012-12-18 21:26:36 +02:00
Andrew Svetlov 737fb89dd1 Issue #16714: use 'raise' exceptions, don't 'throw'.
Patch by Serhiy Storchaka.
2012-12-18 21:14:22 +02:00
Victor Stinner ee36c24d15 Issue #15478: os.lchflags() is not always available when os.chflags() is available 2012-11-13 09:31:51 +01:00
Victor Stinner e667e98faa Issue #16218, #16444: Backport improvment on tests for non-ASCII characters 2012-11-12 01:23:15 +01:00
Victor Stinner 64e039af02 Issue #16414: Fix test_os on Windows, don't test os.listdir() with undecodable
With the ANSI code page 932, os.listdir(b'\xe7') return an empty list (instead
of failing), whereas os.listdir(b'\xff') raises a FileNotFoundError.

It looks like a Windows bug: b'\xe7' directory does not exist,
FindFirstFileA(b'\xe7') fails with ERROR_FILE_NOT_FOUND (2), instead of
ERROR_PATH_NOT_FOUND (3).
2012-11-07 00:10:14 +01:00
Victor Stinner 8b219b2936 Issue #16414: Add support.FS_NONASCII and support.TESTFN_NONASCII
These constants are used to test functions with non-ASCII data, especially
filenames.
2012-11-06 23:23:43 +01:00
Victor Stinner afe1706457 Issue #15478: Use source filename in OSError, not destination filename
And other fixes for Windows:

 * rename, replace and link require arguments of the same type on Windows
 * readlink only supports unicode filenames on Windows
 * os.open() specifies the filename on OSError
2012-10-31 22:47:43 +01:00
Victor Stinner a0c811e439 Issue #15478: Fix again to fix test_os on Windows 2012-10-31 22:16:38 +01:00
Victor Stinner bd54f0eb3a Issue #15478: Fix test_os on FreeBSD
Calling OS functions can fail with errors other than FileNotFoundError: a
FreeBSD buildbot fails for example with a PermissionError.
2012-10-31 01:12:55 +01:00
Victor Stinner f69055efba Issue #15478: Fix test_os on Windows (os.chown is missing) 2012-10-31 01:04:10 +01:00
Victor Stinner 292c835548 Issue #15478: Raising an OSError doesn't decode or encode the filename anymore
Pass the original filename argument to OSError constructor, instead of trying
to encode it to or decode it from the filesystem encoding. This change avoids
an additionnal UnicodeDecodeError on Windows if the filename cannot be decoded
from the filesystem encoding (ANSI code page).
2012-10-30 02:17:38 +01:00
Ezio Melotti c7e139b431 #1087: use proper skips in test_os. 2012-09-26 20:01:34 +03:00
Ned Deily 3a2b97e48a Issue #14992: merge from 3.2 2012-08-08 21:03:02 -07:00
Ned Deily c622f4254b Issue #14992: Prevent test_os test_exist_ok_s_isgid_directory test case
failure on OS X built with 10.4 ABI.
2012-08-08 20:57:24 -07:00
Larry Hastings b40380667c Issue #15202: Consistently use the name "follow_symlinks" for
new parameters in os and shutil functions.  Patch by Serhiy Storchaka.
2012-07-15 10:57:38 -07:00
Victor Stinner 0af71aae2d Issue #16218, #16414, #16444: Backport FS_NONASCII, TESTFN_UNDECODABLE,
TESTFN_NONASCII of test.support from Python 3.4. Backport tests on non-ASCII
paths.
2013-01-03 01:50:30 +01:00
Richard Oudkerk 2240ac1eae Issue #15261: Stop os.stat(fd) crashing on Windows when fd not open. 2012-07-06 12:05:32 +01:00
Larry Hastings c48fe98a7c Issue #15177: Added dir_fd parameter to os.fwalk(). 2012-06-25 04:49:05 -07:00
Georg Brandl 306336bcda Closes #15161: add support for giving path as a fd for truncate() and pathconf(). 2012-06-24 12:55:33 +02:00
Larry Hastings b698d8e7e9 Issue #15154: Add "dir_fd" parameter to os.rmdir, remove "rmdir"
parameter from os.remove / os.unlink.
Patch written by Georg Brandl.  (I'm really looking forward to George
getting commit privileges so I don't have to keep doing checkins on his
behalf.)
2012-06-23 16:55:07 -07:00
Larry Hastings 9cf065cfdc Issue #14626: Large refactoring of functions / parameters in the os module.
Many functions now support "dir_fd" and "follow_symlinks" parameters;
some also support accepting an open file descriptor in place of of a path
string.  Added os.support_* collections as LBYL helpers.  Removed many
functions only previously seen in 3.3 alpha releases (often starting with
"f" or "l", or ending with "at").  Originally suggested by Serhiy Storchaka;
implemented by Larry Hastings.
2012-06-22 16:30:09 -07:00
Victor Stinner 034d0aa217 Issue #14711: os.stat_float_times() has been deprecated. 2012-06-05 01:22:15 +02:00
Gregory P. Smith f0a9a9b502 Fixes Issue #14992: os.makedirs(path, exist_ok=True) would raise an OSError
when the path existed and had the S_ISGID mode bit set when it was
not explicitly asked for.  This is no longer an exception as mkdir
cannot control if the OS sets that bit for it or not.
2012-06-03 14:35:09 -07:00
Gregory P. Smith a81c856436 Fixes Issue #14992: os.makedirs(path, exist_ok=True) would raise an OSError
when the path existed and had the S_ISGID mode bit set when it was not
explicitly asked for.  This is no longer an exception as mkdir cannot control
if the OS sets that bit for it or not.
2012-06-03 14:30:44 -07:00
Hynek Schlawack 39bf90d319 Add two more sorts to test_os.WalkTests I've missed before 2012-05-15 18:40:17 +02:00
Hynek Schlawack c96f5a0457 Sort file list in test_os.WalkTests
Adding new files into the tree lead to buildbot fails as the order wasn't
deterministic.
2012-05-15 17:55:38 +02:00
Hynek Schlawack 66bfcc1b0f #14773: Fix os.fwalk() failing on dangling symlinks 2012-05-15 16:32:21 +02:00
Antoine Pitrou 424246fbf3 Issue #14082: shutil.copy2() now copies extended attributes, if possible.
Patch by Hynek Schlawack.
2012-05-12 19:02:01 +02:00