Commit Graph

2118 Commits

Author SHA1 Message Date
Guido van Rossum c8060a68ff The list(xrange(sys.maxint / 4)) test blew up on 64-bit platforms.
Because ob_size is a 32-bit int but sys.maxint is LONG_MAX which is a
64-bit value, there's no way to make this test succeed on a 64-bit
platform.  So just skip it when sys.maxint isn't 0x7fffffff.

Backport candidate.
2002-09-11 18:32:30 +00:00
Michael W. Hudson 02ff6a9952 A slight change to SET_LINENO-less tracing.
This makes things a touch more like 2.2.  Read the comments in
Python/ceval.c for more details.
2002-09-11 15:36:32 +00:00
Michael W. Hudson 519a342d79 Bunch more tests. 2002-09-11 14:47:51 +00:00
Barry Warsaw ccd9e75b18 test_both(): I believe this was a typo: m is only defined if no
exception occurred so it should only be closed in the else clause.
Without this change we can an UnboundLocalError on Linux:

Traceback (most recent call last):
  File "Lib/test/test_mmap.py", line 304, in ?
    test_both()
  File "Lib/test/test_mmap.py", line 208, in test_both
    m.close()
UnboundLocalError: local variable 'm' referenced before assignment
2002-09-11 02:56:42 +00:00
Barry Warsaw 1a5b9562d6 test_quote_unquote(): Added a test for the rfc822.unquote() patch
(adapted from Quinn Dunkan's mimelib SF patch #573204).
2002-09-11 02:32:57 +00:00
Tim Peters 1b5112ac97 I left some debugging junk in here; removed it. Also replaced a few
more instances of the bizarre "del f; del m" ways to spell .close() (del
won't do any good here under Jython, etc).
2002-09-10 21:19:55 +00:00
Tim Peters 4f4f4d70af A few days ago a test was added here to ensure that creating an mmap
with a size larger than the underlying file worked on Windows.  It
does <wink>.  However, merely creating an mmap that way has the side
effect of growing the file on disk to match the specified size.  A
*later* test assumed that the file on disk was still exactly as it was
before the new "size too big" test was added, but that's no longer true.
So added a hack at the end of the "size too big" test to truncate the
disk file back to its original size on Windows.
2002-09-10 20:49:15 +00:00
Martin v. Löwis 2412853f8e Fix escaping of non-ASCII characters. 2002-09-09 06:17:05 +00:00
Neal Norwitz 522076d1d6 Try to get test to pass on Windows 2002-09-07 05:56:21 +00:00
Jack Jansen 522e7694ed Skip UDP testing for MacPython (for now), it hangs. This may be due to
GUSI/Threading interaction, I'm not sure, but I don't have the time to fix this right now.
2002-09-06 21:57:50 +00:00
Walter Dörwald 9ab7dd4d5b Add a test case that checks that the proper exception is raises
when the replacement from an encoding error callback is itself
unencodable.
2002-09-06 17:21:40 +00:00
Neal Norwitz b567392bbf SF bug # 585792, Invalid mmap crashes Python interpreter
Raise ValueError if user passes a size to mmap which is larger
than the file.
2002-09-05 21:48:07 +00:00
Walter Dörwald 5c1ee17742 Change the unicode.translate docstring to document that
Unicode strings (with arbitrary length) are allowed
as entries in the unicode.translate mapping.

Add a test case for multicharacter replacements.

(Multicharacter replacements were enabled by the
PEP 293 patch)
2002-09-04 20:31:32 +00:00
Guido van Rossum 472c5229c4 Delete the %c test from test_date_time() untill Brett Cannon has time
to fix it.  (It fails when the day of the month is a 1-digit number,
because %c produces space+digit there, while strptime seems to expect
zero+digit somehow.)
2002-09-03 21:10:10 +00:00
Guido van Rossum 602d45194c Add a custom __str__ method to KeyError that applies repr() to the
missing key.  (Also added a guard to SyntaxError__str__ to prevent
calling PyString_Check(NULL).)
2002-09-03 20:24:09 +00:00
Guido van Rossum 6e813188db testConnectTimeout(): set the timeout to a smaller value; 0.02
sometimes wasn't short enough.
2002-09-03 19:17:47 +00:00
Walter Dörwald 8709a420c4 Check whether a string resize is necessary at the end
of PyString_DecodeEscape(). This prevents a call to
_PyString_Resize() for the empty string, which would
result in a PyErr_BadInternalCall(), because the
empty string has more than one reference.

This closes SF bug http://www.python.org/sf/603937
2002-09-03 13:53:40 +00:00
Walter Dörwald 3aeb632c31 PEP 293 implemention (from SF patch http://www.python.org/sf/432401) 2002-09-02 13:14:32 +00:00
Michael W. Hudson 53d58bb369 Further SET_LINENO reomval fixes. See comments in patch #587933.
Use a slightly different strategy to determine when not to call the line
trace function.  This removes the need for the RETURN_NONE opcode, so
that's gone again.  Update docs and comments to match.

Thanks to Neal and Armin!

Also add a test suite.  This should have come with the original patch...
2002-08-30 13:09:51 +00:00
Barry Warsaw 375e0eeacc The test I saw failing this morning just happened to be run at 8am
localtime, which in -0400 is 12 noon GMT.  The bug boiled down to
broken conversion of 12 PM to hour 12 for the '%I %p' format string.

Added a test for this specific condition: Strptime12AMPMTests.  Fix to
_strptime.py coming momentarily.
2002-08-29 15:25:04 +00:00
Guido van Rossum fc26c0730c Undo Barry's change. This file is not imported, it's fed as input to
the tokenize module by test_tokenize.py.  The FutureWarnings only
appeared during installation, and I've figured out a way to suppress
those in a different way.
2002-08-29 15:10:30 +00:00
Guido van Rossum f0253f2bc5 Restore the hex/oct constant tests that Barry commented out for fear
of FutureWarnings.  Added a comment explaining the situation.
2002-08-29 14:57:26 +00:00
Raymond Hettinger 604cd6ae79 complex() was the only numeric constructor that created a new instance
when given its own type as an argument.
2002-08-29 14:22:51 +00:00
Barry Warsaw 18bd11205d Fixed three exceptions in the Plain integers test, although I'm not
sure these are the best fixes.

- Test maxint-1 against the negative octal constant -020000000000

- Comment out the tests for oct -1 and hex -1, since 037777777777 and
  0xffffffff raise FutureWarnings now and in Python 2.4 those
  constants will produce positive values, not negative values.  So the
  existing test seems to test something that won't be true in 2.4.
2002-08-29 13:09:47 +00:00
Barry Warsaw c6f80fd995 The test_tokenize output has changed slightly, by the addition of some
trailing `L's.
2002-08-29 12:56:59 +00:00
Barry Warsaw 266e6b1f4b Quite down some FutureWarnings. 2002-08-28 16:36:11 +00:00
Tim Peters ea76c98014 Implemented <, <=, >, >= for sets, giving subset and proper-subset
meanings.  I did not add new, e.g., ispropersubset() methods; we're
going nuts on those, and, e.g., there was no "friendly name" for
== either.
2002-08-25 18:43:10 +00:00
Tim Peters 93d8d48c15 TestSubset(): Generalized the framework to support testing upcoming
<, <=, etc methods too.
2002-08-25 18:21:47 +00:00
Tim Peters 4127e91d20 Rewrote all remaining assert stmts. 2002-08-25 18:02:29 +00:00
Tim Peters 62c62438ff Simplified construction of the test suite. 2002-08-25 17:49:04 +00:00
Tim Peters de830ca4eb Simplified code building sets of characters. 2002-08-25 17:40:29 +00:00
Tim Peters a777799040 Ack! Virtually every test here relied on an assert stmt. assert stmts
should never be used in tests.  Repaired dozens, but more is needed.
2002-08-25 17:38:49 +00:00
Tim Peters 0bbb30830c Simplified the setup for is-subset testing. 2002-08-25 17:22:23 +00:00
Raymond Hettinger e87ab3fefe Removed < <= > >= from the API. Implemented as comparisons of the
underlying dictionaries, there were no reasonable use cases (lexicographic
sorting of a list of sets is somewhat esoteric).  Frees the operators
for other uses (such as strict subset and superset comparisons).

Updated documentation and test suite accordingly.
2002-08-24 07:33:06 +00:00
Raymond Hettinger 1b9f5d4c1a At Tim Peter's suggestion, propagated GvR's binary operator changes to
the inplace operators.  The strategy is to have the operator overloading
code do the work and then to define equivalent method calls which rely on
the operators.  The changes facilitate proper application of TypeError
and NonImplementedErrors.

Added corresponding tests to the test suite to make sure both the operator
and method call versions get exercised.

Add missing tests for difference_update().
2002-08-24 06:19:02 +00:00
Raymond Hettinger 045e51a9a5 Expanded tests for sets of sets. 2002-08-24 02:56:01 +00:00
Guido van Rossum 2023c9b84a Fix SF bug 599128, submitted by Inyeol Lee: .replace() would do the
wrong thing for a unicode subclass when there were zero string
replacements.  The example given in the SF bug report was only one way
to trigger this; replacing a string of length >= 2 that's not found is
another.  The code would actually write outside allocated memory if
replacement string was longer than the search string.

(I wonder how many more of these are lurking?  The unicode code base
is full of wonders.)

Bugfix candidate; this same bug is present in 2.2.1.
2002-08-23 18:50:21 +00:00
Guido van Rossum 8b1a6d694f Code by Inyeol Lee, submitted to SF bug 595350, to implement
the string/unicode method .replace() with a zero-lengt first argument.
Inyeol contributed tests for this too.
2002-08-23 18:21:28 +00:00
Tim Peters 7c7efe9073 Got rid of the toy _Set class, in favor of sets.Set. 2002-08-23 17:55:54 +00:00
Greg Ward c6edb37268 Test an em-dash with adjacent punctuation. 2002-08-22 21:27:05 +00:00
Greg Ward 715debd3d1 Factored out BaseTestCase.check_split() method -- use it wherever
we need to test TextWrapper._split().
2002-08-22 21:16:25 +00:00
Greg Ward 24a1c9cff5 Test _split() method in test_unix_options(). 2002-08-22 21:12:54 +00:00
Greg Ward 34f995b3c1 Add test_unix_options() to WrapTestCase to test for SF bug #596434. 2002-08-22 21:10:07 +00:00
Guido van Rossum ae4693129a Standardize behavior: no docstrings in test functions. 2002-08-22 20:22:16 +00:00
Guido van Rossum 9eee554bd9 Standardize behavior: no docstrings in test functions. Also use
unittest.makeSuite() rather than loader.loadTestsFromTestCase().
2002-08-22 20:21:30 +00:00
Guido van Rossum 327af775b8 Standardize behavior: no docstrings in test functions. Also strip
trailing whitespace.
2002-08-22 20:13:47 +00:00
Guido van Rossum 1c48654e01 Document that docstrings are verboten for test functions.
Expand the example to show some actual test functions, and a setUp()
and tearDown() method.
2002-08-22 20:08:14 +00:00
Guido van Rossum 8ccd9b63cc Standardize behavior: no docstrings in test functions. Also get rid
of dummy_test_TemporaryFile class; when NamedTemporaryFile and
TemporaryFile are the same, simply don't add a test suite for
TemporaryFile.
2002-08-22 20:02:03 +00:00
Guido van Rossum a5ce2e8c17 Standardize behavior: no docstrings in test functions; add a proper
test_main() that creates a suite and runs it.  Don't mess with sys.path!!!
2002-08-22 19:57:50 +00:00
Greg Ward 9ad15a3dff Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
em-dashes -- like this -- properly.  (Also--like this.  Although this
usage may be incompatible with fixing bug #596434; we shall see.)
2002-08-22 19:47:27 +00:00
Guido van Rossum 32c2ae7f4a Standardize behavior: no docstrings in test functions. 2002-08-22 19:45:32 +00:00
Guido van Rossum 2e8bba5c21 Standardize behavior: create a single suite merging all test cases. 2002-08-22 19:40:33 +00:00
Guido van Rossum 7e8fdba01c Standardize behavior: no docstrings in test functions; create a single
suite merging all test cases.
2002-08-22 19:38:14 +00:00
Guido van Rossum cb682584a3 Made it more readable. 2002-08-22 19:18:56 +00:00
Greg Ward f69d3c9849 Simplification/cleanup in IndentTestCases. 2002-08-22 19:06:45 +00:00
Greg Ward fd030e46a7 Factor LongWordTestCase out of WrapTestCase, and rename its methods
(tests) from test_funky_punc() to test_break_long() and
test_long_words() to test_nobreak_long().
2002-08-22 19:02:37 +00:00
Greg Ward 13c53c64db Rename base test case class to (yawn) BaseTestCase. 2002-08-22 18:57:26 +00:00
Greg Ward ee413849b5 Ditch the whole loop-over-subcases way of working. Add check_wrap() to
base class (WrapperTestCase) instead, and call it repeatedly in the
methods that used to have a loop-over-subcases.  Much simpler.

Rename perennial temp variable 't' to 'text'.
2002-08-22 18:55:38 +00:00
Greg Ward 9ebba9ace3 Simplify and reformat the use of 'subcases' lists (and following
for-loops) in test_simple(), test_wrap_short() test_hyphenated(), and
test_funky_punc().
2002-08-22 18:45:02 +00:00
Greg Ward 3dc94e14c0 Add comment header block.
Remove some useless comments (redundant, or info presumably available in
  PyUnit docs).
2002-08-22 18:37:50 +00:00
Greg Ward f67657811c Conform to standards documented in README:
*  lowercase test*() methods
  * define test_main() and use it instead of unittest.main()
Kill #! line.
Improve some test names and docstrings.
2002-08-22 18:35:49 +00:00
Greg Ward 90c0b071ed Test script for the textwrap module. Kindly provided by Peter Hansen
<peter@engcorp.com> based on a test script that's been kicking around my
home directory for a couple of months now and only saw the light of day
because I included it when I sent textwrap.py to python-dev for review.
2002-08-22 18:11:10 +00:00
Raymond Hettinger c3e61e5c52 Add regression test for proper construction of sets of sets. 2002-08-21 06:38:44 +00:00
Guido van Rossum c9196bc88d Rename popitem() to pop(). (An idea from SF patch 597444.) 2002-08-20 21:51:59 +00:00
Guido van Rossum 76afbd9aa4 Fix some endcase bugs in unicode rfind()/rindex() and endswith().
These were reported and fixed by Inyeol Lee in SF bug 595350.  The
endswith() bug was already fixed in 2.3, but this adds some more test
cases.
2002-08-20 17:29:29 +00:00
Guido van Rossum d6cf3af8f7 Set classes and their unit tests, from sandbox. 2002-08-19 16:19:15 +00:00
Raymond Hettinger 5959c559df Added __pow__(a,b) to the operator module. Completes the pattern of
all operators having a counterpart in the operator module.

Closes SF bug #577513.
2002-08-19 03:19:09 +00:00
Andrew MacIntyre 1d0eeec279 OS/2 EMX behaves like Windows where file permissions are concerned 2002-08-18 06:47:19 +00:00
Guido van Rossum e888cdc683 Get rid of _once(); inlining it takes less code. :-)
Also, don't call gettempdir() in the default expression for the 'dir'
argument to various functions; use 'dir=None' for the default and
insert 'if dir is None: dir = gettemptir()' in the bodies.  That way
the work done by gettempdir is postponed until needed.
2002-08-17 14:50:24 +00:00
Guido van Rossum 787410680b Patch by Zack W to make test_noinherit() more robust: spawn a Python
subprocess that does the right checks.  This now works on Windows as
well.
2002-08-17 11:41:01 +00:00
Neal Norwitz 68ee0128a2 Drop the number of test files to 100 for all the tests 2002-08-16 19:28:59 +00:00
Tim Peters 80703c8930 check_events(): This was failing under -O, due to not expecting any
LINE events when not __debug__.  But we get them anyway under -O now,
so just stop special-casing non-__debug__ mode.
2002-08-16 02:27:15 +00:00
Barry Warsaw 0a51b58e6b base64.decodestring('') should return '' instead of raising an
exception.  The bug fix for SF #430849 wasn't quite right.  This
closes SF bug #595671.  I'll backport this to Python 2.2.
2002-08-15 22:14:24 +00:00
Michael W. Hudson dd32a91cc0 This is my patch
[ 587993 ] SET_LINENO killer

Remove SET_LINENO.  Tracing is now supported by inspecting co_lnotab.

Many sundry changes to document and adapt to this change.
2002-08-15 14:59:02 +00:00
Skip Montanaro 8c91337221 forgot the best part - the new tests...
see patch 586561
2002-08-15 01:28:54 +00:00
Guido van Rossum 54df53a352 More changes of DeprecationWarning to FutureWarning. 2002-08-14 18:38:27 +00:00
Guido van Rossum 88b1defb6f The filterwarnings() call here should be updated to filter out
FutureWarning.
2002-08-14 17:54:48 +00:00
Tim Peters 04490bf225 tempfile's mkstemp(): Changed last argument from
binary=True
to
    text=False

by BDFL Pronouncement.  All other changes follow from this.  The change
to the docs is ready to go, but blocked by another JackMacLock in the
doc directory.
2002-08-14 15:41:26 +00:00
Guido van Rossum 20f0b36a04 test_many(): open only 100 temp files, not 1000. Some systems don't
allow that many open files per process.  I don't see that 1000 makes
any difference for the test.
2002-08-14 14:52:02 +00:00
Martin v. Löwis eb3f00aeeb Check for trailing backslash. Fixes #593656. 2002-08-14 08:22:50 +00:00
Martin v. Löwis 8a8da798a5 Patch #505705: Remove eval in pickle and cPickle. 2002-08-14 07:46:28 +00:00
Tim Peters 632a4fbd4d runtest(): I don't know why we don't just use TESTFN, but if we have to
do bizarre things to get a temp file, I changed it to use mkstemp instead
of NamedTemporaryFile.  This tried to leave the file open while passing
its name to execfile().  On Win2K (but not Win9X), though, a file created
with O_TEMPORARY cannot be opened again, so the test failed with a
permission error when execfile tried to open it.  Closer to the truth:
a file created with O_TEMPORARY can be opened again, but only if the
file is also created with SHARE_DELETE access via the Win32 CreateFile()
function.  There's no way to get at that from MS's version of libc, though
(we'd have to ditch the "std" C file functions in favor of Win32 API
calls).
2002-08-14 01:05:57 +00:00
Tim Peters 7f270ba860 Added a test specifically to tickle Karatsuba; it costs no appreciable
runtime.
2002-08-13 21:06:55 +00:00
Guido van Rossum 8b056da6c8 Add tests for including __dict__ and/or __weakref__ in __slots__.
Add some more rigor to slotmultipleinheritance().
2002-08-13 18:26:26 +00:00
Neal Norwitz f9dd0f1924 Add test for SF bug # 575229, multiple inheritance w/ slots dumps core
Fix already checked in by Guido
2002-08-13 17:16:49 +00:00
Jason Tishler 83499db4f0 Bug #556025: list(xrange(1e9)) --> seg fault
Close the bug report again -- this time for Cygwin due to a newlib bug.
See the following for the details:

	http://sources.redhat.com/ml/newlib/2002/msg00369.html

Note that this commit is only a documentation (i.e., comment) change.
2002-08-13 11:42:41 +00:00
Tim Peters d0876b859d test_division(): Added one larger digits value, to ensure that the
"lopsided Karatsuba" driver also gets some exercise.
2002-08-13 02:24:25 +00:00
Tim Peters 28b0e2a7f8 Machines-- and Python --are a lot faster in relevant ways since this
test was written.  So boosted the number of "digits" this generates, and
also beefed up the "* / divmod" test to tickle numbers big enough to
trigger the Karatsuba algorithm.  It takes about 2 seconds now on my box.
2002-08-13 02:17:11 +00:00
Guido van Rossum 558fc977c5 Don't use hex constants representing negative numbers. 2002-08-12 22:01:24 +00:00
Guido van Rossum dc15c27f50 Suppress warnings about test_grammar.py that can't be suppressed inside
that file itself (because it's the parser that reports them).
2002-08-12 21:55:51 +00:00
Guido van Rossum a6fa0e6f2e Portable way of producing unsigned 32-bit hex output to print the
CRCs.
2002-08-12 15:26:05 +00:00
Guido van Rossum baf29638da Shut up warnings about hex()/oct() that can't be avoided. 2002-08-12 15:16:20 +00:00
Marc-André Lemburg cc8764ca9d Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.
u'%c' will now raise a ValueError in case the argument is an
integer outside the valid range of Unicode code point ordinals.

Closes SF bug #593581.
2002-08-11 12:23:04 +00:00
Tim Peters d92ae840e9 test_saveall(): Another small simplification; plus s/l/L/g.
test_del(), test_del_newclass():  No need to use apply() in these.
2002-08-11 04:15:09 +00:00
Tim Peters a1ad3f08ad And one more simplification to test_saveall(). 2002-08-10 21:32:16 +00:00
Tim Peters 4803c126a6 test_saveall(): Simplified a little, given that we only expect one item
in gc.garbage (so no need to loop looking for it -- it's there or it's
not).
2002-08-10 21:29:56 +00:00
Tim Peters c708c0a8c4 If any trash happened to be sitting around waiting to get collected at
the time it's called, test_saveall() made it look a leak, triggering
bogus warnings from regrtest's -l (findleaks) mode.
2002-08-10 21:20:54 +00:00
Guido van Rossum 40af889081 Disallow class assignment completely unless both old and new are heap
types.  This prevents nonsense like 2.__class__ = bool or
True.__class__ = int.
2002-08-10 05:42:07 +00:00
Fred Drake 56d1266193 Add tests for weakref support for generator-iterators.
Part of fixing SF bug #591704.
2002-08-09 18:37:10 +00:00
Tim Peters ca3ac7f639 There's no distinction among 'user', 'group' and 'world' permissions
on Win32, so tests that assume there are such distinctions can't
pass.  Fiddled them to work.
2002-08-09 18:13:51 +00:00
Tim Peters a0d55de877 Whitespace normalization. 2002-08-09 18:01:01 +00:00
Guido van Rossum 4aa21aa5b3 Test finalizers and GC from inside __del__ for new classes. 2002-08-09 17:38:16 +00:00
Guido van Rossum 3b0a3293c3 Massive changes from SF 589982 (tempfile.py rewrite, by Zack
Weinberg).  This changes all uses of deprecated tempfile functions to
the recommended ones.
2002-08-09 16:38:32 +00:00
Guido van Rossum 0e54871f82 Check-in of the most essential parts of SF 589982 (tempfile.py
rewrite, by Zack Weinberg).  This replaces most code in tempfile.py
(please review!!!) and adds extensive unit tests for it.

This will cause some warnings in the test suite; I'll check those in
soon, and also the docs.
2002-08-09 16:14:33 +00:00
Guido van Rossum 0f5f0b8057 Test for Neil's fix to correctly invoke __rmul__. 2002-08-09 16:11:37 +00:00
Guido van Rossum f36921c4b0 Unicode replace() method with empty pattern argument should fail, like
it does for 8-bit strings.
2002-08-09 15:36:48 +00:00
Raymond Hettinger c35491ee3a Moved inplace add and multiply methods from UserString to MutableString.
Closes SF Bug #592573 where inplace add mutated a UserString.
Added unittests to verify the bug is cleared.
2002-08-09 01:37:06 +00:00
Raymond Hettinger 8da9da0ccc Revised the test suite for 'contains' to use the test() function argument
rather than vereq().  While it was effectively testing regular strings, it
ignored the test() function argument when called by test_userstring.py.
2002-08-09 00:43:38 +00:00
Guido van Rossum e531e296fa testSendAll(): loop until all data is read; this was necessary at
least on OS/2 (see note on SF patch 555085 by A I MacIntyre) but
looks like the test *could* fail on any other platform too -- there's
no guarantee that recv() reads all data.
2002-08-08 20:28:34 +00:00
Tim Peters 469cdad822 Whitespace normalization. 2002-08-08 20:19:19 +00:00
Guido van Rossum 8c94383fa8 Replace docstrings on test functions witrh comments -- then unittest
prints function and module names, which is more informative now that
we repeat some tests in slightly modified subclasses.

Add a test for read() until EOF.

Add test suites for line-buffered (bufsize==1) and a small custom
buffer size (bufsize==2).

Restructure testUnbufferedRead() somewhat to avoid a potentially
infinite loop.
2002-08-08 01:00:28 +00:00
Guido van Rossum 10e3f411b0 Tighten the unbuffered readline test to distinguish between the two lines. 2002-08-07 19:02:49 +00:00
Guido van Rossum 29bf9157ec Oops. I accidentally commented out some tests. 2002-08-07 16:03:06 +00:00
Guido van Rossum e9f6614ea3 "Unbuffered" mode of class _fileobject wasn't actually unbuffered,
and this broke a Zope "pipelining" test which read multiple responses
from the same connection (this attaches a new file object to the
socket for each response).  Added a test for this too.

(I want to do some code cleanup too, but I thought I'd first fix
the problem with as little code as possible, and add a unit test
for this case.  So that's what this checkin is about.)
2002-08-07 15:46:19 +00:00
Raymond Hettinger ca84d65ca7 Expanded the unittests for the new width sensitive PyUnicode_Contains(). 2002-08-06 23:08:51 +00:00
Guido van Rossum 2d702465b3 Add testcase for SF bug 574207 (chained __slots__ dealloc segfault).
Fix forthcoming.
2002-08-06 21:28:28 +00:00
Barry Warsaw e06741704e Added a test for PyUnicode_Contains() taking into account the width of
Py_UNICODE.
2002-08-06 19:03:56 +00:00
Guido van Rossum 0855dd8938 Bump the LOOPS count. 50,000 iterations takes about 5 seconds on my
machine -- that feels just right.
2002-08-06 17:21:20 +00:00
Guido van Rossum 8ee5243434 Mark xreadlines deprecated. Don't use f.xreadlines() in test_iter.py. 2002-08-06 17:14:04 +00:00
Barry Warsaw 817918cc3c Committing patch #591250 which provides "str1 in str2" when str1 is a
string of longer than 1 character.
2002-08-06 16:58:21 +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
Fred Drake 63c4220f61 We only need to check for StopIteration here. 2002-08-05 22:16:40 +00:00
Martin v. Löwis 4c561b36a0 Test whether a Cyrillic text correctly appears in a Unicode literal. 2002-08-05 01:32:09 +00:00
Tim Peters 6782d6aa91 We don't really need the name of the test in the "test skipped" msg, and
having it there causes the line to wrap.
2002-08-04 22:55:35 +00:00
Tim Peters 283ead8bf2 Oops! Forgot the closing paren. 2002-08-04 22:52:30 +00:00
Tim Peters 32ef169339 Finally got around to figuring out and documenting why this test fails
on Windows.  The test_sequence() ERROR is easily repaired if we're
willing to add an os.unlink() line to mhlib's updateline().  The
test_listfolders FAIL I gave up on -- I don't remember enough about Unix
link esoterica to recall why a link count of 2 is something a well-
written program should be keenly interested in <wink>.
2002-08-04 22:35:31 +00:00
Martin v. Löwis a729daf2e4 Add encoding declaration. 2002-08-04 17:28:33 +00:00
Tim Peters 8d30b1e673 I don't know what's going on with this test, but the last change from
Piers obviously couldn't have passed on any platform.  Fiddling it so it
works (for a meaning of "works" no stronger than "doesn't fail" <wink>).
2002-08-04 06:53:18 +00:00
Piers Lauder dc96ae6c79 revert to version 1.2 2002-08-03 11:14:43 +00:00
Tim Peters 0cd53a6c37 Added new heapreplace(heap, item) function, to pop (and return) the
currently-smallest value, and add item, in one gulp.  See the second
N-Best algorithm in the test suite for a natural use.
2002-08-03 10:10:10 +00:00
Tim Peters 30e0beab6d Remove cut 'n paste silliness. 2002-08-03 02:17:41 +00:00
Tim Peters aa7d24319e Minor fiddling, including a simple class to implement a heap iterator
in the test file.  I have docs for heapq.heapify ready to check in, but
Jack appears to have left behind a stale lock in the Doc/lib directory.
2002-08-03 02:11:26 +00:00
Tim Peters 28c25527c2 Hmm! I thought I checked this in before! Oh well.
Added new heapify() function, which transforms an arbitrary list into a
heap in linear time; that's a fundamental tool for using heaps in real
life <wink>.

Added heapyify() test.  Added a "less naive" N-best algorithm to the test
suite, and noted that this could actually go much faster (building on
heapify()) if we had max-heaps instead of min-heaps (the iterative method
is appropriate when all the data isn't known in advance, but when it is
known in advance the tradeoffs get murkier).
2002-08-02 21:48:06 +00:00
Tim Peters d2cf1ab0e2 check_invariant(): Use the same child->parent "formula" used by heapq.py. 2002-08-02 19:41:54 +00:00
Tim Peters d9ea39db84 Don't use true division where int division was intended. For that matter,
don't use division at all.
2002-08-02 19:16:44 +00:00
Guido van Rossum 0b19178736 Adding the heap queue algorithm, per discussion in python-dev last
week.
2002-08-02 18:29:53 +00:00
Skip Montanaro 13a5678a51 regression test for the whichdb module 2002-08-02 17:10:10 +00:00
Skip Montanaro f4433303a8 testGetServByName shouldn't check for getservbyname - the socket module
should always have it.
2002-08-02 15:52:30 +00:00
Tim Peters d5f4359458 New test %sort. This takes a sorted list, picks 1% of the list positions
at random, and replaces the elements at those positions with new random
values.  I was pleasantly surprised by how fast this goes!  It's hard to
conceive of an algorithm that could special-case for this effectively.
Plus it's exactly what happens if a burst of gamma rays corrupts your
sorted database on disk <wink>.

 i    2**i  *sort  ...  %sort
15   32768   0.18  ...   0.03
16   65536   0.24  ...   0.04
17  131072   0.53  ...   0.08
18  262144   1.17  ...   0.16
19  524288   2.56  ...   0.35
20 1048576   5.54  ...   0.77
2002-08-02 05:46:09 +00:00
Skip Montanaro d3c884d4ea modify testGetServByName so it tries a few different protocols. In this day
and age of rampant computer breakins I imagine there are plenty of systems
with telnet disabled.  Successful check of at least one getservbyname() call
is required for success
2002-08-02 02:19:46 +00:00
Guido van Rossum 0dbab4c560 SF patch 588728 (Nathan Srebro).
The __delete__ method wrapper for descriptors was not supported

(I added a test, too.)

2.2 bugfix candidate.
2002-08-01 14:39:25 +00:00
Tim Peters 2d8b765cc9 New test for sorting sanity. Note that this will fail in earlier Pythons,
in the stability tests.

Bizarre:  this takes 11x longer to run if and only if test_longexp is
run before it, on my box.  The bigger REPS is in test_longexp, the
slower this gets.  What happens on your box?  It's not gc on my box
(which is good, because gc isn't a plausible candidate here).

The slowdown is massive in the parts of test_sort that implicitly
invoke a new-style class's __lt__ or __cmp__ methods.  If I boost
REPS large enough in test_longexp, even the test_sort tests on an array
of size 64 visibly c-r-a-w-l.  The relative slowdown is even worse in
a debug build.  And if I reduce REPS in test_longexp, the slowdown in
test_sort goes away.

test_longexp does do horrid things to Win98's management of user
address space, but I thought I had made that a whole lot better a month
or so ago (by overallocating aggressively in the parser).
2002-08-01 02:23:06 +00:00
Tim Peters 108b7918b0 Reverting this to rev 1.3. It's apparently broken everywhere at rev
1.6, and pierslauder didn't respond to email about it on Monday.
2002-07-31 16:42:33 +00:00
Guido van Rossum b995eb79a0 Enable test_socket again, if only to prevent mistakes like Jeremy
thinking that he was running his new test by running "make test".
Also, I can't get this to fail any more.  Your turn. :-)
2002-07-31 16:08:40 +00:00
Jeremy Hylton cbd5b89571 Repair testNtoH for large long arguments.
If the long is large enough, the return value will be a negative int.
In this case, calling the function a second time won't return the
original value passed in.
2002-07-31 15:57:39 +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
Thomas Heller 3e1c18ad0c Fix SF 588452: debug build crashes on marshal.dumps([128] * 1000).
See there for a description.

Added test case.

Bugfix candidate for 2.2.x, not sure about previous versions:
probably low priority, because virtually no one runs debug builds.
2002-07-30 11:40:57 +00:00
Michael W. Hudson 56796f672f Fix for
[ 587875 ] crash on deleting extended slice

The array code got simpler, always a good thing!
2002-07-29 14:35:04 +00:00
Neal Norwitz 88fe4ff5a9 Fix the problem of not raising a TypeError exception when doing:
'%g' % '1'
    '%d' % '1'

Add a test for these conditions
Fix the test so that if not exception is raise, this is a failure
2002-07-28 16:44:23 +00:00
Piers Lauder 139bccb2f0 remove redundant import 2002-07-27 07:10:14 +00:00
Piers Lauder 8b6bb4f743 remove redundant code 2002-07-27 07:08:38 +00:00
Piers Lauder 385a77acad remove o/s dependancy from test 2002-07-27 00:38:30 +00:00
Jack Jansen aeb6a60e03 Reorganized so the test is skipped if os.popen() doesn't exist (in stead of failing). 2002-07-26 11:33:49 +00:00
Fred Drake fd83374fe2 Remove duplicate checks of the Node.allnodes variable. 2002-07-25 20:40:28 +00:00
Jeremy Hylton c075e197d6 Extended socket.htonl and ntohl to accept longs.
Fixes SF bug #568322.

The code should raise an OverflowError if the long is > 32 bits, even
on platforms where sizeof(long) > 4.
2002-07-25 16:01:12 +00:00
Jeremy Hylton b8a690d42a Remove test that was none too picky about whether attributes exist. 2002-07-25 15:37:23 +00:00
Barry Warsaw b5da606dfd Oops, missed an import of test_support. 2002-07-23 19:23:22 +00:00
Barry Warsaw 1bfab7bc01 A few updates about how/where to import test_support from. 2002-07-23 19:13:45 +00:00
Barry Warsaw 04f357cffe Get rid of relative imports in all unittests. Now anything that
imports e.g. test_support must do so using an absolute package name
such as "import test.test_support" or "from test import test_support".

This also updates the README in Lib/test, and gets rid of the
duplicate data dirctory in Lib/test/data (replaced by
Lib/email/test/data).

Now Tim and Jack can have at it. :)
2002-07-23 19:04:11 +00:00
Tim Peters 7ea39b135a New test "+sort", tacking 10 random floats on to the end of a sorted
array.  Our samplesort special-cases the snot out of this, running about
12x faster than *sort.  The experimental mergesort runs it about 8x
faster than *sort without special-casing, but should really do better
than that (when merging runs of different lengths, right now it only
does something clever about finding where the second run begins in
the first and where the first run ends in the second, and that's more
of a temp-memory optimization).
2002-07-21 17:37:03 +00:00
Neal Norwitz d69030db4f Get popen test to work even if python is not in the path 2002-07-20 20:35:13 +00:00
Tim Peters 0a30e648e0 Added new test "3sort". This is sorted data but with 3 random exchanges.
It's a little better than average for our sort.
2002-07-20 04:21:51 +00:00
Guido van Rossum 65692578b7 Move the setting of os.environ['LANGUAGE'] to setup(), and reset it to
'en' in teardown().  This way hopefully test_time.py won't fail.
2002-07-20 00:36:38 +00:00
Barry Warsaw d33d47401d Shut the test up and add a missing import 2002-07-19 22:44:23 +00:00
Barry Warsaw 190390b026 The email package's tests live much better in a subpackage
(i.e. email.test), so move the guts of them here from Lib/test.  The
latter directory will retain stubs to run the email.test tests using
Python's standard regression test.

test_email_torture.py is a torture tester which will not run under
Python's test suite because I don't want to commit megs of data to
that project (it will fail cleanly there).  When run under the mimelib
project it'll stress test the package with megs of message samples
collected from various locations in the wild.
2002-07-19 22:31:10 +00:00
Fred Drake c441f7b3a6 Follow PyXML: Remove all prints from successful tests. This means we can
also drop the output file.
2002-07-19 22:16:41 +00:00
Guido van Rossum 246a58a10b Remove a few lines that aren't used and cause problems on platforms
where recvfrom() on a TCP stream returns None for the address.
This should address the remaining problems on FreeBSD.
2002-07-19 19:23:54 +00:00
Guido van Rossum 00efe7e798 Pure Python strptime implementation by Brett Cannon. See SF patch 474274.
Also adds tests.
2002-07-19 17:04:46 +00:00
Michael W. Hudson f0d777c56b A few days ago, Guido said (in the thread "[Python-Dev] Python
version of PySlice_GetIndicesEx"):

> OK.  Michael, if you want to check in indices(), go ahead.

Then I did what was needed, but didn't check it in.  Here it is.
2002-07-19 15:47:06 +00:00
Guido van Rossum b6cc7d2806 Add test for previous core dump when sending on closed socket with
timeout.

Added small sleeps to _testAccept() and _testRecv() in
NonBlockingTCPTests, to reduce race conditions (I know, this is not
the solution!)
2002-07-19 12:46:46 +00:00
Guido van Rossum 9d0c8cee66 Add default timeout functionality. This adds setdefaulttimeout() and
getdefaulttimeout() functions to the socket and _socket modules, and
appropriate tests.
2002-07-18 17:08:35 +00:00
Tim Peters 8b6ec79b74 Gave this a facelift: "/" vs "//", whrandom vs random, etc. Boosted
the default range to end at 2**20 (machines are much faster now).
Fixed what was quite a arguably a bug, explaining an old mystery:  the
"!sort" case here contructs what *was* a quadratic-time disaster for
the old quicksort implementation.  But under the current samplesort, it
always ran much faster than *sort (the random case).  This never made
sense.  Turns out it was because !sort was sorting an integer array,
while all the other cases sort floats; and comparing ints goes much
quicker than comparing floats in Python.  After changing !sort to chew
on floats instead, it's now slower than the random sort case, which
makes more sense (but is just a few percent slower; samplesort is
massively less sensitive to "bad patterns" than quicksort).
2002-07-18 15:53:32 +00:00
Tim Peters 30d4896511 Gave hotshot.LogReader a close() method, to allow users to close the
file object that LogReader opens.  Used it then in test_hotshot; the
test passes again on Windows.  Thank Guido for the analysis.
2002-07-18 14:54:28 +00:00
Tim Peters ba8c069eb9 test_hotshot fails on Windows now. Added XXX comment explaining why,
and that I don't know how to fix it.  Fred?
2002-07-17 23:52:58 +00:00
Guido van Rossum 7fadcabdee Add a test for the 'closed' attribute on the C-profiler object. 2002-07-17 16:12:53 +00:00
Jeremy Hylton ed375e18d1 Add missing comma. 2002-07-17 15:56:55 +00:00
Guido van Rossum 11c3f0999f Add a rather generous set of tests allowed to be skipped on sunos5. 2002-07-17 15:08:24 +00:00
Tim Peters c7b6bedecf Use sys.executable to run Python, as suggested by Neal Norwitz. 2002-07-17 00:34:26 +00:00
Guido van Rossum 674eae65ea Bunch of tests to make sure that StopIteration is a sink state. 2002-07-16 21:48:11 +00:00
Tim Peters c411dbaeee Whitespace normalization. 2002-07-16 21:35:23 +00:00
Tim Peters 012b69cb30 The atexit module effectively turned itself off if sys.exitfunc already
existed at the time atexit first got imported.  That's a bug, and this
fixes it.

Also reworked test_atexit.py to test for this too, and to stop using
an "expected output" file, and to test what actually happens at exit
instead of just simulating what it thinks atexit will do at exit.

Bugfix candidate, but it's messy so I'll backport to 2.2 myself.
2002-07-16 19:30:59 +00:00
Andrew MacIntyre 754140e163 Tim_one's change to aggressively overallocate nodes when adding child
nodes (in Parser/node.c) resolves the gross memory consumption
exhibited by the EMX runtime on OS/2, so the test should be exercised
on this platform.
2002-07-15 12:03:19 +00:00
Jeremy Hylton b2622a452a Remove httplib from tested modules.
The test of httplib makes it difficult to maintain httplib.  There are
two many idioms that pyclbr doesn't seem to understand, and I don't
understand how to update these tests to make them work.

Also remove commented out test of urllib2.
2002-07-12 15:54:37 +00:00
Jeremy Hylton 39c03808c7 Change _begin() back to begin().
Client code could create responses explicitly.
2002-07-12 14:04:09 +00:00
Tim Peters c62b95e550 test_trashcan() and supporting class Ouch(): Jeremy noted that this test
takes much longer to run in the context of the test suite than when run in
isolation.  That's because it forces a large number of full collections,
which take time proportional to the total number of gc'ed objects in the
whole system.

But since the dangerous implementation trickery that caused this test to
fail in 2.0, 2.1 and 2.2 doesn't exist in 2.3 anymore (the trashcan
mechanism stopped doing evil things when the possibility for compiling
without cyclic gc was taken away), such an expensive test is no longer
justified.  This checkin leaves the test intact, but fiddles the
constants to reduce the runtime by about a factor of 5.
2002-07-11 19:07:45 +00:00
Tim Peters 72351b9649 subtype_resurrection(): Removed unused import. 2002-07-11 18:39:56 +00:00
Jeremy Hylton df3f793516 Extend function() to support an optional closure argument.
Also, simplify some ref counting for other optional arguments.
2002-07-11 18:30:27 +00:00
Tim Peters 14cb1e1eff subtype_resurrection(): The test suite with -l properly reported the
immortal object here as a leak.  Made the object mortal again at the end.
2002-07-11 18:26:21 +00:00
Tim Peters 45228ca827 Repaired optimistic comment in new test. 2002-07-11 07:09:42 +00:00
Tim Peters 2484aaea15 Added a test that provokes the hypothesized (in my last checkin comment)
debug-build failure when an instance of a new-style class is resurrected
by a __del__ method -- we simply never had any code that tried this.

This is already fixed in 2.3 CVS.  In 2.2.1, it blows up via

    Fatal Python error: GC object already in linked list

I'll fix it in 2.2.1 CVS next.
2002-07-11 06:56:07 +00:00
Tim Peters 5e5ca56476 assertHasattr(): Made failure msg better than useless.
test_others():  httplib failed in two new ways.  Blame Thumb Boy <wink>.
2002-07-10 02:37:21 +00:00
Barry Warsaw c53b29e2a7 ndiffAssertEqual(): Stringify the arguments before running
.splitlines() on them, since they may be Header instances.

test_multilingual(), test_header_ctor_default_args(): New tests of
make_header() and that Header can take all default arguments.
2002-07-09 16:36:36 +00:00
Thomas Heller 6b17abf6c0 Fix SF Bug 564931: compile() traceback must include filename. 2002-07-09 09:23:27 +00:00
Barry Warsaw 329d3af443 TestEmailBase.ndiffAssertEqual(): Python 2.1's difflib doesn't have an
ndiff function, so just alias it to assertEqual in that case.

Various: make sure all openfile()/read()'s are wrapped in
try/finally's so the file gets closed.

A bunch of new tests checking the corner cases for multipart/digest
and message/rfc822.
2002-07-09 02:38:24 +00:00
Barry Warsaw e5270aea23 New files which test the corners of multipart/message and
message/rfc822 compliance.
2002-07-09 02:36:10 +00:00
Jack Jansen 1695bcb848 Got rid of special case for Macintosh realloc slowdown: Tim fixed the problem. 2002-07-08 10:07:25 +00:00
Jeremy Hylton 6d0a4c79cf Fix for SF bug #432621: httplib: multiple Set-Cookie headers
If multiple header fields with the same name occur, they are combined
according to the rules in RFC 2616 sec 4.2:

Appending each subsequent field-value to the first, each separated by
a comma. The order in which header fields with the same field-name are
received is significant to the interpretation of the combined field
value.
2002-07-07 16:51:37 +00:00
Tim Peters ba78bc4a32 printlist(): Replaced the guts with a call to textwrap. Yay! 2002-07-04 19:45:06 +00:00
Martin v. Löwis 7d650ca83b Implement the encoding argument for toxml and toprettyxml.
Document toprettyxml.
2002-06-30 15:05:00 +00:00
Barry Warsaw 1969817486 Another test of long headers. 2002-06-29 15:23:39 +00:00