Commit Graph

1840 Commits

Author SHA1 Message Date
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