Commit Graph

48 Commits

Author SHA1 Message Date
Ezio Melotti 2623a37852 Merged revisions 86596 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r86596 | ezio.melotti | 2010-11-20 21:04:17 +0200 (Sat, 20 Nov 2010) | 1 line

  #9424: Replace deprecated assert* methods in the Python test suite.
........
2010-11-21 13:34:58 +00:00
Ezio Melotti 187f93d986 Use "x in y" instead of y.find(x) != -1. 2010-03-17 14:22:34 +00:00
Georg Brandl a4f46e1292 Remove unused imports in test modules. 2010-02-07 17:03:15 +00:00
Ezio Melotti dde5b94875 #7092: Silence more py3k warnings. Patch by Florent Xicluna. 2010-02-03 05:37:26 +00:00
Senthil Kumaran ce8e33a095 Reverting the Revision: 77368. I committed Flox's big patch for tests by
mistake. ( It may come in for sure tough)
2010-01-08 19:04:16 +00:00
Senthil Kumaran 3ddc435af6 Fixing - Issue7026 - RuntimeError: dictionary changed size during iteration. Patch by flox 2010-01-08 18:41:40 +00:00
Benjamin Peterson 5c8da86f3a convert usage of fail* to assert* 2009-06-30 22:57:08 +00:00
Antoine Pitrou 47a5f48006 Try to restore the old test_file and test_univnewlines as new, different files
(with the right revisions this time, hopefully)
2009-06-12 20:41:52 +00:00
Antoine Pitrou 1969059327 Issue #6215: backport the 3.1 io lib 2009-06-12 20:14:08 +00:00
Kristján Valur Jónsson fd4c872726 issue 4804: Provide checks for the format string of strftime, and for the "mode" string of fopen on Windows. These strings are user provided from python and so we can avoid invoking the C runtime invalid parameter handler by first checking that they are valid. 2009-02-04 10:05:25 +00:00
Benjamin Peterson fe231b07e4 #4764 set IOError.filename when trying to open a directory on POSIX platforms 2008-12-29 17:47:42 +00:00
Skip Montanaro f205c13fac As a result of a regression that snuck into 2.5.3 add a test case that
ensures that when you try to read from a file opened for writing an IOError
is raised.
2008-12-23 03:30:15 +00:00
Jeffrey Yasskin 2d873bd68b Issue 4597: Fix several cases in EvalFrameEx where an exception could be
"raised" without setting x, err, or why to let the eval loop know.
2008-12-08 18:55:24 +00:00
Amaury Forgeot d'Arc 17617a07d1 #3965: on Windows, open() crashes if the filename or the mode is invalid,
and if the filename is a unicode string.

Reviewed by Martin von Loewis.
2008-09-25 20:52:56 +00:00
Amaury Forgeot d'Arc bdd941fac3 #3242: fix a crash in "print", if sys.stdout is set to a custom object,
whose write() method installs another sys.stdout.

Will backport.
2008-07-01 20:38:04 +00:00
Gregory P. Smith aa63d0d4af Make file objects as thread safe as the underlying libc FILE* implementation.
close() will now raise an IOError if any operations on the file object
are currently in progress in other threads.

Most code was written by Antoine Pitrou (pitrou).  Additional testing,
documentation and test suite cleanup done by me (gregory.p.smith).

Fixes issue 815646 and 595601 (as well as many other bugs and
references to this problem dating back to the dawn of Python).
2008-04-06 23:11:17 +00:00
Georg Brandl ad61bc8d9b #2067: file.__exit__() now calls subclasses' close() method. 2008-02-23 15:11:18 +00:00
Georg Brandl e7ec81f130 Test file.__exit__. 2006-06-09 18:29:52 +00:00
Neal Norwitz c9778a8951 Fix grammar and reflow 2006-06-09 05:54:18 +00:00
Tim Peters 0556e9b119 testUnicodeOpen(): I have no idea why, but making this
test clean up after itself appears to fix the test failures
when test_optparse follows test_file.

test_main():  Get rid of TESTFN no matter what.  That's
also enough to fix the mystery failures.  Doesn't hurt
to fix them twice :-)
2006-06-09 04:02:06 +00:00
Tim Peters dbb82f623f AutoFileTests.tearDown(): Removed mysterious undocumented
try/except.  Remove TESTFN.

Throughout:  used open() instead of file(), and wrapped
long lines.
2006-06-09 03:51:41 +00:00
Tim Peters 520d8ddd97 Whitespace normalization.
Since test_file is implicated in mysterious test failures
when followed by test_optparse, if I had any brains I'd
look at the checkin that last changed test_file ;-)
2006-06-09 02:11:02 +00:00
Georg Brandl 442b49e938 Convert test_file to unittest. 2006-06-08 14:50:53 +00:00
Georg Brandl 7b90e168f3 Bug #1462152: file() now checks more thoroughly for invalid mode
strings and removes a possible "U" before passing the mode to the
C library function.
2006-05-18 07:01:27 +00:00
Neal Norwitz 9cdfa4c98c Skip the test for sys.stdin.seek(-1) on OSF/1 (Tru64) since it does Bad Things
like cause the interpreter to exit abruptly.  If there's a way to fix this,
it would be good to really fix it.  It could just be the operation of the
std C library and we just aren't supposed to do that.

When the test case is skipped, we print a message so the user can check
for themselves.
2006-04-03 05:27:05 +00:00
Tim Peters cffcfed126 New test code failed to close the file. This caused
test_file to fail on Windows in reality (can't delete
a still-open file), but a new bare "except:" hid that
test_file failed on Windows, and leaving behind the
still-open TESTFN caused a cascade of bogus failures
in later tests.

So, close the file, and stop hiding failure to unlink.
2006-02-14 17:41:18 +00:00
Thomas Wouters c45251a485 SF patch #1397960: When mixing file-iteration and
readline/readlines/read/readinto, loudly break by raising ValueError, rather
than silently deliver data out of order or hitting EOF prematurely.

Probably not a bugfix candidate, even though it affects no 'working' code.
2006-02-12 11:53:32 +00:00
Neal Norwitz a716eabca7 Revert r41662 and the part of 41552 that originally caused the problem
(calling ftell(stdin) doesn't seem defined).  So we won't test errors
from ftell unless we can do it portably.
2005-12-15 05:25:09 +00:00
Neal Norwitz ec77645df9 mwh spotted a copied error message, make it unique (and correct) 2005-12-05 01:23:48 +00:00
Neal Norwitz a6fc397a80 Fix SF #1373161, r41552 broke test_file on OS X
You apparently can seek(0) on sys.stdin on OS X.
But you can't go backwards, so seek(-1).
2005-12-05 01:17:03 +00:00
Neal Norwitz fcf4435ae0 Improve test coverage. Hope the test_file changes work the same on windows. 2005-11-27 20:37:43 +00:00
Skip Montanaro bbf12ba7b2 Disallow opening files with modes 'aU' or 'wU' as specified by PEP
278. Closes bug 967182.
2005-05-20 03:07:06 +00:00
Barry Warsaw b180c06a54 Fix tests dependent on the exception raised by non-settable descriptors. 2005-04-20 19:41:36 +00:00
Raymond Hettinger cb87bc8e7e Add weakref support to array.array and file objects. 2004-05-31 00:35:52 +00:00
Andrew MacIntyre 4e10ed3b86 If a file is opened with an explicit buffer size >= 1, repeated
close() calls would attempt to free() the buffer already free()ed on
the first close().     [bug introduced with patch #788249]

Making sure that the buffer is free()ed in file object deallocation is
a belt-n-braces bit of insurance against a memory leak.
2004-04-04 07:01:35 +00:00
Tim Peters f1827cfaab SF bug 801631: file.truncate fault on windows.
file_truncate():  C doesn't define what fflush(fp) does if fp is open
for update, and the preceding I/O operation on fp was input.  On Windows,
fflush() actually changes the current file position then.  Because
Windows doesn't support ftruncate() directly, this not only caused
Python's file.truncate() to change the file position (contra our docs),
it also caused the file not to change size.

Repaired by getting the initial file position at the start, restoring
it at the end, and tossing all the complicated micro-efficiency checks
trying to avoid "provably unnecessary" seeks.  file.truncate() can't
be a frequent operation, and seeking to the current file position has
got to be cheap anyway.

Bugfix candidate.
2003-09-07 03:30:18 +00:00
Tim Peters 015dd82136 Somewhere along the way, the softspace attr of file objects became read-
only.  Repaired, and added new tests to test_file.py.
2003-05-04 04:16:52 +00:00
Guido van Rossum 3c668c1256 Add next and __iter__ to the list of file methods that should raise
ValueError when called for a closed file.
2002-08-06 15:58:24 +00:00
Barry Warsaw 408b6d34de Complete the absolute import patch for the test suite. All relative
imports of test modules now import from the test package.  Other
related oddities are also fixed (like DeprecationWarning filters that
weren't specifying the full import part, etc.).  Also did a general
code cleanup to remove all "from test.test_support import *"'s.  Other
from...import *'s weren't changed.
2002-07-30 23:27:12 +00:00
Martin v. Löwis f90ae20354 Patch #488073: AtheOS port. 2002-06-11 06:22:31 +00:00
Neal Norwitz b1295da59e There is no TestError, use TestFailed appropriately 2002-04-01 18:59:20 +00:00
Neal Norwitz 62f5a9d6c2 Convert file.readinto() to stop using METH_OLDARGS & PyArg_Parse.
Add test for file.readinto().
2002-04-01 00:09:00 +00:00
Neal Norwitz 653d85fc86 SF Patch #494867 test file methods
Test that the file methods raise ValueError when called on a closed file.
Test .isatty()
Test name, closed attributes
2002-01-01 19:11:13 +00:00
Jeremy Hylton 734c7fb131 Fiddle with new test cases -- verify that we get a sensible error
message for bad mode argument -- so that it doesn't fail on Windows.

It's hack.  We know that errno is set to 0 in this case on Windows, so
check for that specifically.
2001-11-09 19:34:43 +00:00
Jeremy Hylton 41c8321252 Fix SF buf #476953: Bad more for opening file gives bad msg.
If fopen() fails with EINVAL it means that the mode argument is
invalid.  Return the mode in the error message instead of the
filename.
2001-11-09 16:17:24 +00:00
Marc-André Lemburg 3661908a6a This patch removes all uses of "assert" in the regression test suite
and replaces them with a new API verify(). As a result the regression
suite will also perform its tests in optimization mode.

Written by Marc-Andre Lemburg. Copyright assigned to Guido van Rossum.
2001-01-17 19:11:13 +00:00
Fred Drake 2ec80faae5 Clean up the temporary file when done with it. 2000-10-23 16:59:35 +00:00
Marc-André Lemburg fa44d794bd New test suite for file objects by Jeremy Hilton. This will need
to be extended somewhat -- right now it only tests the .writelines()
method.
2000-08-25 22:37:31 +00:00