Commit Graph

1117 Commits

Author SHA1 Message Date
Tim Peters e63415ead8 SF patch #421922: Implement rich comparison for dicts.
d1 == d2 and d1 != d2 now work even if the keys and values in d1 and d2
don't support comparisons other than ==, and testing dicts for equality
is faster now (especially when inequality obtains).
2001-05-08 04:38:29 +00:00
Jeremy Hylton 4c889011db SF patch 419176 from MvL; fixed bug 418977
Two errors in dict_to_map() helper used by PyFrame_LocalsToFast().
2001-05-08 04:08:59 +00:00
Tim Peters 7ae2229afb This is a test showing SF bug 422177. It won't trigger until I check in
another change (to test_import.py, which simply imports the new file).  I'm
checking this piece in now, though, to make it easier to distribute a patch
for x-platform checking.
2001-05-08 03:58:01 +00:00
Tim Peters 8572b4fedf Generalize zip() to work with iterators.
NEEDS DOC CHANGES.
More AttributeErrors transmuted into TypeErrors, in test_b2.py, and,
again, this strikes me as a good thing.
This checkin completes the iterator generalization work that obviously
needed to be done.  Can anyone think of others that should be changed?
2001-05-06 01:05:02 +00:00
Tim Peters ef0c42d4e5 Get rid of silly 5am "del" stmts. 2001-05-05 21:36:52 +00:00
Tim Peters cb8d368b82 Reimplement PySequence_Contains() and instance_contains(), so they work
safely together and don't duplicate logic (the common logic was factored
out into new private API function _PySequence_IterContains()).
Visible change:
    some_complex_number  in  some_instance
no longer blows up if some_instance has __getitem__ but neither
__contains__ nor __iter__.  test_iter changed to ensure that remains true.
2001-05-05 21:05:01 +00:00
Tim Peters 75f8e35ef4 Generalize PySequence_Count() (operator.countOf) to work with iterators. 2001-05-05 11:33:43 +00:00
Tim Peters de9725f135 Make 'x in y' and 'x not in y' (PySequence_Contains) play nice w/ iterators.
NEEDS DOC CHANGES
A few more AttributeErrors turned into TypeErrors, but in test_contains
this time.
The full story for instance objects is pretty much unexplainable, because
instance_contains() tries its own flavor of iteration-based containment
testing first, and PySequence_Contains doesn't get a chance at it unless
instance_contains() blows up.  A consequence is that
    some_complex_number in some_instance
dies with a TypeError unless some_instance.__class__ defines __iter__ but
does not define __getitem__.
2001-05-05 10:06:17 +00:00
Tim Peters 2cfe368283 Make unicode.join() work nice with iterators. This also required a change
to string.join(), so that when the latter figures out in midstream that
it really needs unicode.join() instead, unicode.join() can actually get
all the sequence elements (i.e., there's no guarantee that the sequence
passed to string.join() can be iterated over *again* by unicode.join(),
so string.join() must not pass on the original sequence object anymore).
2001-05-05 05:36:48 +00:00
Tim Peters 6912d4ddf0 Generalize tuple() to work nicely with iterators.
NEEDS DOC CHANGES.
This one surprised me!  While I expected tuple() to be a no-brainer, turns
out it's actually dripping with consequences:
1. It will *allow* the popular PySequence_Fast() to work with any iterable
   object (code for that not yet checked in, but should be trivial).
2. It caused two std tests to fail.  This because some places used
   PyTuple_Sequence() (the C spelling of tuple()) as an indirect way to test
   whether something *is* a sequence.  But tuple() code only looked for the
   existence of sq->item to determine that, and e.g. an instance passed
   that test whether or not it supported the other operations tuple()
   needed (e.g., __len__).  So some things the tests *expected* to fail
   with an AttributeError now fail with a TypeError instead.  This looks
   like an improvement to me; e.g., test_coercion used to produce 559
   TypeErrors and 2 AttributeErrors, and now they're all TypeErrors.  The
   error details are more informative too, because the places calling this
   were *looking* for TypeErrors in order to replace the generic tuple()
   "not a sequence" msg with their own more specific text, and
   AttributeErrors snuck by that.
2001-05-05 03:56:37 +00:00
Tim Peters 15d81efb8a Generalize reduce() to work with iterators.
NEEDS DOC CHANGES.
2001-05-04 04:39:21 +00:00
Tim Peters 8bc10b0c57 Purge redundant cut&paste line. 2001-05-03 23:58:47 +00:00
Tim Peters 4e9afdca39 Generalize map() to work with iterators.
NEEDS DOC CHANGES.
Possibly contentious:  The first time s.next() yields StopIteration (for
a given map argument s) is the last time map() *tries* s.next().  That
is, if other sequence args are longer, s will never again contribute
anything but None values to the result, even if trying s.next() again
could yield another result.  This is the same behavior map() used to have
wrt IndexError, so it's the only way to be wholly backward-compatible.
I'm not a fan of letting StopIteration mean "try again later" anyway.
2001-05-03 23:54:49 +00:00
Tim Peters efdae3939a Remove redundant copy+paste code. 2001-05-03 07:09:25 +00:00
Tim Peters c307453162 Generalize max(seq) and min(seq) to work with iterators.
NEEDS DOC CHANGES.
2001-05-03 07:00:32 +00:00
Marc-André Lemburg 542fe56cb9 Fix for bug #417030: "print '%*s' fails for unicode string" 2001-05-02 14:21:53 +00:00
Tim Peters 0e57abf0cd Generalize filter(f, seq) to work with iterators. This also generalizes
filter() to no longer insist that len(seq) be defined.
NEEDS DOC CHANGES.
2001-05-02 07:39:38 +00:00
Tim Peters 8ae2df483c Whitespace normalization. 2001-05-02 05:54:44 +00:00
Fred Drake 0e540c391f Added tests for Weak*Dictionary iterator support.
Refactored some object initialization to be more reusable.
2001-05-02 05:44:22 +00:00
Tim Peters f553f89d45 Generalize list(seq) to work with iterators. This also generalizes list()
to no longer insist that len(seq) be defined.
NEEDS DOC CHANGES.
This is meant to be a model for how other functions of this ilk (max,
filter, etc) can be generalized similarly.  Feel encouraged to grab your
favorite and convert it!
Note some cute consequences:
    list(file) == file.readlines() == list(file.xreadlines())
    list(dict) == dict.keys()
    list(dict.iteritems()) = dict.items()
    list(xrange(i, j, k)) == range(i, j, k)
2001-05-01 20:45:31 +00:00
Jeremy Hylton ddc4fd03b1 Fix 2.1 nested scopes crash reported by Evan Simpson
The new test case demonstrates the bug.  Be more careful in
symtable_resolve_free() to add a var to cells or frees only if it
won't be added under some other rule.

XXX Add new assertion that will catch this bug.
2001-04-27 02:29:40 +00:00
Fred Drake 8f42e2b1fa Update test to accomodate the change to the namespace_separator parameter
of ParserCreate().

Added assignment tests for the ordered_attributes and specified_attributes
values, similar to the checks for the returns_unicode attribute.
2001-04-25 16:03:54 +00:00
Guido van Rossum 8b48cf9016 Add test suite for iterators. 2001-04-21 13:33:54 +00:00
Tim Peters a3f98d6bac Give UserDict new __contains__ and __iter__ methods. 2001-04-21 09:13:15 +00:00
Guido van Rossum 0dbb4fba4c Implement, test and document "key in dict" and "key not in dict".
I know some people don't like this -- if it's really controversial,
I'll take it out again.  (If it's only Alex Martelli who doesn't like
it, that doesn't count as "real controversial" though. :-)

That's why this is a separate checkin from the iterators stuff I'm
about to check in next.
2001-04-20 16:50:40 +00:00
Jeremy Hylton 3090694068 Fix compileall.py so that it fails on SyntaxErrors
The changes cause compilation failures in any file in the Python
installation lib directory to cause the install to fail.  It looks
like compileall.py intended to behave this way, but a change to
py_compile.py and a separate bug defeated it.

Fixes SF bug #412436

This change affects the test suite, which contains several files that
contain intentional errors.  The solution is to extend compileall.py
with the ability to skip compilation of selected files.

In the test suite, rename nocaret.py and test_future[3..7].py to start
with badsyntax_nocaret.py and badsyntax_future[3..7].py.  Update the
makefile to skip compilation of these files.  Update the tests to use
the name names for imports.

NB compileall.py is changed so that compile_dir() returns success only
if all recursive calls to compile_dir() also check success.
2001-04-18 01:19:28 +00:00
Fred Drake a0a4ab1772 Add a test case for Weak*Dictionary.update() that would have caught a
recently reported bug; also exposed some other bugs in the implementation.
2001-04-16 17:37:27 +00:00
Guido van Rossum 42f92da307 Change the test data to ask for class C from module __main__ rather
than from module pickletester.  Using the latter turned out to cause
the test to break when invoked as "import test.test_pickle" or "import
test.autotest".
2001-04-16 00:28:21 +00:00
Guido van Rossum fc349862d4 In order to make this test work on Windows, the test locale has to be
set to 'en' there -- Windows does not understand the 'en_US' locale.
The test succeeds there.
2001-04-15 13:15:56 +00:00
Guido van Rossum f3ee46b82a Set the SO_REUSEADDR socket option in the server thread -- this seems
needed on some platforms (e.g. Solaris 8) when the test is run twice
in quick succession.
2001-04-15 00:42:13 +00:00
Guido van Rossum 9df3eabd6e Add "import thread" at the top of the module; this prevents us from
failing later when Python is compiled without threading but a failing
'threading' module can be imported due to an earlier (caught) attempt.
2001-04-14 14:35:43 +00:00
Fred Drake b891891d00 If the sunaudiodev module is available but we cannot find an audio
device to use, skip this test instead of allowing an error to occur
when we attempt to play sound on the absent device.

Verified by Mark Favas.
2001-04-14 03:10:12 +00:00
Fred Drake 705088e65f Added regression test for SF bug #415660 (failure to invalidate all
references to an object before calling registered callbacks).

Change last uses of verify() to self.assert_().
2001-04-13 17:18:15 +00:00
Guido van Rossum 361c535863 Fix typo in comment (the module is now called _testcapi, not _test). 2001-04-13 17:03:04 +00:00
Jeremy Hylton c76770c68c Change error message raised when free variable is not yet bound. It
now raises NameError instead of UnboundLocalError, because the var in
question is definitely not local.  (This affects test_scope.py)

Also update the recent fix by Ping using get_func_name().  Replace
tests of get_func_name() return value with call to get_func_desc() to
match all the other uses.
2001-04-13 16:51:46 +00:00
Jeremy Hylton 79fa2b6073 Add test for SF bug #405427 2001-04-13 14:57:44 +00:00
Jeremy Hylton 3bee2f6011 Update to reflect new tokenize_test.py 2001-04-13 14:55:18 +00:00
Jeremy Hylton a4553c04fd There's no need for the tokenize tests to include a SyntaxError. 2001-04-13 14:36:51 +00:00
Martin v. Löwis 88ad12afac Patch #415777: new grouping strategy.
fixes bug #414940, and redoes the fix for #129417 in a different way.
It also fixes a number of other problems with locale-specific formatting:
If there is leading or trailing spaces, then no grouping should be applied
in the spaces, and the total length of the string should not be changed
due to grouping.
Also added test case which works only if the en_US locale is available.
2001-04-13 08:09:50 +00:00
Tim Peters fff5325078 Bug 415514 reported that e.g.
"%#x" % 0
blew up, at heart because C sprintf supplies a base marker if and only if
the value is not 0.  I then fixed that, by tolerating C's inconsistency
when it does %#x, and taking away that *Python* produced 0x0 when
formatting 0L (the "long" flavor of 0) under %#x itself.  But after talking
with Guido, we agreed it would be better to supply 0x for the short int
case too, despite that it's inconsistent with C, because C is inconsistent
with itself and with Python's hex(0) (plus, while "%#x" % 0 didn't work
before, "%#x" % 0L *did*, and returned "0x0").  Similarly for %#X conversion.
2001-04-12 18:38:48 +00:00
Tim Peters 711088d9b8 Fix for SF bug #415514: "%#x" % 0 caused assertion failure/abort.
http://sourceforge.net/tracker/index.php?func=detail&aid=415514&group_id=5470&atid=105470
For short ints, Python defers to the platform C library to figure out what
%#x should do.  The code asserted that the platform C returned a string
beginning with "0x".  However, that's not true when-- and only when --the
*value* being formatted is 0.  Changed the code to live with C's inconsistency
here.  In the meantime, the problem does not arise if you format a long 0 (0L)
instead.  However, that's because the code *we* wrote to do %#x conversions on
longs produces a leading "0x" regardless of value.  That's probably wrong too:
we should drop leading "0x", for consistency with C, when (& only when) formatting
0L.  So I changed the long formatting code to do that too.
2001-04-12 00:35:51 +00:00
Tim Peters 4642cb9ac9 Reverting the "unixware7" patch: atan2(0, 1) should be 0, regardless of
platform.  If it returns pi on the unixware7 platform, they have a bug in
their libm atan2.
2001-04-12 00:24:41 +00:00
Guido van Rossum 2242f2fbd0 Unixware 7 support by Billy G. Allie (SF patch 413011) 2001-04-11 20:58:20 +00:00
Jeremy Hylton ceccc3c037 Test cases for examples of ext call error handling.
Fix to SF bug #414743 based on Michael Hudson's patch #414750.
2001-04-11 13:53:35 +00:00
Fred Drake bf43691ccb Use the WeakKeyDictionary and WeakValueDictionary classes directly
instead of using the mapping() function.
2001-04-10 19:09:35 +00:00
Guido van Rossum 75ebb29f88 Some other tests, when failing, don't always remove their TESTFN file.
Try to do it for them, so our mkdir() operation doesn't fail.
2001-04-10 15:01:20 +00:00
Guido van Rossum a5af2148ee When doing the quick test to see whether large files are supported,
catch IOError as well as OverflowError.  I found that on Tru64 Unix
this was raised; probably because the OS (or libc) doesn't support
large files but the architecture is 64 bits!
2001-04-10 14:50:51 +00:00
Guido van Rossum bfce016a30 When zlib can't be imported, zipfile raises RuntimeError, which causes
the test to be marked as failing rather than skipped.  Add an explicit
"import zlib" to prevent this.
2001-04-10 14:46:39 +00:00
Tim Peters e089c68871 Test full range of native ints. This exposes two more binary pickle
bugs on sizeof(long)==8 machines.  pickle.py has no idea what it's
doing with very large ints, and variously gets things right by accident,
computes nonsense, or generates corrupt pickles.  cPickle fails on
cases 2**31 <= i < 2**32:  since it *thinks* those are 4-byte ints
(the "high 4 bytes" are all zeroes), it stores them in the (signed!) BININT
format, so they get unpickled as negative values.
2001-04-10 03:41:41 +00:00
Tim Peters 461922a005 Pickles have a number of storage formats for various sizes and kinds of
integers, but the std tests don't exercise most of them.  Repair that.

CAUTION:  I expect this to fail on boxes with sizeof(long)==8, in the
part of test_cpickle (but not test_pickle) trying to do a binary mode
(not text mode) load of the embedded BINDATA pickle string.  Once that
hypothesized failure is confirmed, I'll fix cPickle.c.
2001-04-09 20:07:05 +00:00
Tim Peters c58440fcef No functional change -- just added whitespace in places so I could follow
the logic better.  Will be adding some additional tests later today.
2001-04-09 17:16:31 +00:00
Tim Peters 7e01e284cb Whitespace normalization. 2001-04-08 07:44:07 +00:00
Tim Peters eb26f95906 Since Guido fiddled Cookie.py to work with doctest, it's a Good Thing to
have the std test suite exercise the Cookie doctests too.
2001-04-06 21:20:58 +00:00
Tim Peters f95423e265 Remove lines for asynchat & asyncore, as they've now got their own test. 2001-04-06 18:59:17 +00:00
Guido van Rossum dca060c55c After testing the test on Unix, several improvements:
- Use push() instead of send(), and make these calls in main().

- Sleep a second to give the server thread time to initialize itself.
2001-04-06 16:43:49 +00:00
Guido van Rossum 66172520ee Add test for asynchat. This also tests asyncore. 2001-04-06 16:32:22 +00:00
Tim Peters 7d3bad66e4 Sf bug [ #412214 ] ZipFile constructor leaves files open.
This applies the patch Fred Drake created to fix it.
I'm checking it in since I had to apply the patch anyway in order
to test its behavior on Windows.
2001-04-04 18:56:49 +00:00
Tim Peters a19a168ccc Whitespace normalization. 2001-03-29 04:36:09 +00:00
Guido van Rossum 1417144f33 Based on info from Jens@digicool.com, add 'darwin1' to the list of
BSD-style OS'es.  Makes sense, really.
2001-03-28 01:14:56 +00:00
Fred Drake 3d9091ece1 Itamar Shtull-Trauring <itamar@maxnm.com>:
Add support to zipfile to support opening an archive represented by an
open file rather than a file name.
2001-03-26 15:49:24 +00:00
Barry Warsaw 2108bc7ab0 main(): Application of SF patch #405851, which allows this test to be
used by Jython.  The tests in this module expect C locale, so be
explicit about setting that (for CPython).  However, in Jython, there
is no C locale, so instead be explicit about setting the US locale.
Closes the patch.
2001-03-23 20:24:07 +00:00
Barry Warsaw 559f6680c2 In Jython, `@' is not allowed in module names. Extend the TESTFN test
to use "$test" when in Jython.  Closes SF patch #403668.
2001-03-23 18:04:02 +00:00
Barry Warsaw 6870bba459 Make socket.getservbyname test optional on socket module having that
attribute.  Jython does not have this function.

Closes SF patch #403667.
2001-03-23 17:40:16 +00:00
Barry Warsaw dfdac1af4d Several changes for Jython portability. This closes SF patch
#403666.  Specifically,

In codestr, force `c' to be global.  It's unclear what the semantics
should be for a code object compiled at module scope, but bound and
run in a function.  In CPython, `c' is global (by accident?) while in
Jython, `c' is local.  The intent of the test clearly is to make `c'
global, so let's be explicit about it.

Jython also does not have a __builtins__ name in the module's
namespace, so we use a more portable alternative (though I'm not sure
why the test requires "__builtins__" in the g namespace).

Finally, skip the new.code() test if the new module doesn't have a
`code' attribute.  Jython will never have this.
2001-03-23 16:13:30 +00:00
Ka-Ping Yee f170d7fea7 Don't have trace() skip the top frame; return them all. 2001-03-23 05:14:10 +00:00
Fred Drake b0fefc5121 Convert the weakref test suite to PyUNIT, and add tests that exercise weak
references on function objects and both bound and unbound methods.
2001-03-23 04:22:45 +00:00
Fred Drake 84a5934f8a When the regression test is run in verbose mode, make the PyUNIT-based
tests a little noisier, providing more progress information.
2001-03-23 04:21:17 +00:00
Fredrik Lundh 015415ed14 SRE 2.1b2: increase the chances that the sre test works on other
machines...
2001-03-22 23:48:28 +00:00
Fredrik Lundh 987f1332fe SRE 2.1b2: forgot to update one output file (sorry, Fred!) 2001-03-22 23:29:04 +00:00
Fredrik Lundh 17741be466 SRE 2.1b1: don't do unicode tests under 1.5.2, or on unicode
strings/patterns.
2001-03-22 15:51:28 +00:00
Fredrik Lundh b25e1ad253 sre 2.1b2 update:
- take locale into account for word boundary anchors (#410271)
- restored 2.0's *? behaviour (#233283, #408936 and others)
- speed up re.sub/re.subn
2001-03-22 15:50:10 +00:00
Thomas Wouters b0dbeef1c4 Allow the process of reading back what we wrote to a pty to transform
linefeeds into carriagereturn-linefeeds (which is apparently what IRIX
does.) Also add some comments, an extra test and reorganize it a bit.
2001-03-22 14:50:24 +00:00
Steve Purcell 5ddd1a8dcb Updated to latest PyUnit version (1.31 in PyUnit CVS); test_support.py
changed accordingly.
2001-03-22 08:45:36 +00:00
Guido van Rossum f6e47ad4bd Check that f.keys() == [] right after creation -- this prevents bugs
like the one I just fixed to come back and haunt us.
2001-03-22 00:40:23 +00:00
Tim Peters 24a4191160 Changed doctest to run tests in alphabetic order of name.
This makes verbose-mode output easier to dig thru, and removes an accidental
dependence on the order of dict.items() (made visible by recent changes to
dictobject.c).
2001-03-21 23:07:59 +00:00
Jeremy Hylton 09ccc3a22a Test that traceback module works with SyntaxErrors with or without carets. 2001-03-21 20:33:04 +00:00
Fred Drake 91751143eb Add test cases for the fnmatch module. 2001-03-21 18:29:25 +00:00
Fred Drake cd1b1dd6d2 Just import sys at the top instead of inside lots of functions.
Add some helpers for supporting PyUNIT-based unit testing.
2001-03-21 18:26:33 +00:00
Jeremy Hylton 5c7a2513ec Add tests for recent changes:
- global stmt in class does not affect free vars in methods
- locals() works with free and cell vars
2001-03-21 16:44:39 +00:00
Tim Peters eba5130e4f Addrf simple test that import is case-sensitive. 2001-03-21 03:58:16 +00:00
Jeremy Hylton e241e29f3d Add test for a list comprehension that is nested in the left-hand part
of another list comp.  This caused crashes reported as SF bugs 409230
and 407800.

Note that the new tests are in a function so that the name lookup code
isn't affected by how many *other* list comprehensions are in the same
scope.
2001-03-19 20:42:11 +00:00
Tim Peters 9e6f278fc1 Repair test_doctest's expected-output file (Guido added some new output). 2001-03-18 20:14:25 +00:00
Tim Peters 0f33604e17 SF bug [ #409448 ] Complex division is braindead
http://sourceforge.net/tracker/?func=detail&aid=409448&group_id=5470&atid=105470
Now less braindead.  Also added test_complex.py, which doesn't test much, but
fails without this patch.
2001-03-18 08:21:57 +00:00
Tim Peters 30edd2387d Whitespace normalization. 2001-03-16 08:29:48 +00:00
Guido van Rossum a8f7e59761 Oops. A RISCOS patch I forgot to check in. 2001-03-13 09:31:07 +00:00
Jeremy Hylton 5b44a67bdb Add test to verify that nested functions with free variables don't
cause the free variables to leak.
2001-03-13 02:01:12 +00:00
Fred Drake 63085d4d1e Import the nested_scopes feature twice, to exercise the patch introduced
to avoid segfaults when more than one feature is named in the future
statement.

This tests for regression of SF bug #407394.
2001-03-10 02:18:47 +00:00
Tim Peters 243bff4708 Clean up junk files left behind by imp.load_source(). 2001-03-04 00:30:25 +00:00
Ka-Ping Yee 9054344d14 Replace literal '@test' with TESTFN. 2001-03-02 05:48:10 +00:00
Guido van Rossum ca956e2e47 When catching errors from os.rmdir(), test for os.error, not IOError! 2001-03-02 05:46:17 +00:00
Tim Peters d74bc432b2 Make names in __future__.py bind to class instances instead of 2-tuples.
Suggested on c.l.py by William Tanksley, and I like it.
2001-03-02 02:53:08 +00:00
Tim Peters fc35de409b test_global was broken by some recent checkin. Repairing. 2001-03-02 01:48:16 +00:00
Guido van Rossum 9aa643cf69 Test interaction of global and nested scopes -- thanks to Samuele Pedroni. 2001-03-01 20:35:45 +00:00
Tim Peters 251083142f Whitespace normalization. 2001-03-01 08:31:39 +00:00
Skip Montanaro 40fc16059f final round of __all__ lists (I hope) - skipped urllib2 because Moshe may be
giving it a slight facelift
2001-03-01 04:27:19 +00:00
Fred Drake 5c015344a6 Add tests for the .copy() methods of both weak dictionary classes. 2001-03-01 03:06:53 +00:00
Jeremy Hylton 2922ea8235 Add test case for global stmt at module level.
Fix test_grammar so that it ignores warning about global stmt at
module level in exec.
2001-02-28 23:49:19 +00:00
Jeremy Hylton 42efed0fc3 update output to reflect exception that is now raised 2001-02-28 23:24:22 +00:00
Jeremy Hylton 150a6640f5 Fix filter for SyntaxErrors 2001-02-28 22:50:15 +00:00
Jeremy Hylton 62e2c7e3df Add regression test for future statements. This adds eight files, but
seven are not tests in their own right; these files are mentioned in
regrtest.
2001-02-28 17:48:06 +00:00
Tim Peters 85ba673b0a Whitespace normalization. 2001-02-28 08:26:44 +00:00
Fred Drake 6e7e485d5d Added regression test for SF tracker bug #403871: AttributeError in
ZipFile.__del__() when there was an IOError opening the underlying
    file in ZipFile.__init__().

    This is an odd test: since the exception is in the __del__() method,
    it is not propogated.  This test will trigger it but regrtest.py
    does not detect the failure (not sure why); we are dependent on it
    actually being noticed by a user to get a new bug report if it ever
    fails.  ;-(

    On the other hand, this makes sure that code gets exercised, so
    a failure could be noticed!
2001-02-28 05:34:16 +00:00
Jeremy Hylton 8e43cd7929 verify that warnings are issued for bogus uses of global 2001-02-28 01:51:01 +00:00
Andrew M. Kuchling 6efc6e7832 Patch #404680: disables the nis module and enables the dl module when
building under Cygwin.  Makes some fixes to the dlmodule in order to
    compile with Cygwin.
2001-02-27 20:54:23 +00:00
Jeremy Hylton 5941d191de add from __future__ import nested_scopes to strings passed to compile 2001-02-27 20:23:58 +00:00
Martin v. Löwis 5e1633365d Patch #403985: Add support for weak-keyed dictionaries 2001-02-27 18:36:56 +00:00
Ka-Ping Yee 6397c7c9a9 inspect: a module for getting information out of live Python objects 2001-02-27 14:43:21 +00:00
Jeremy Hylton 29906eef3a Preliminary support for future nested scopes
compile.h: #define NESTED_SCOPES_DEFAULT 0 for Python 2.1
           __future__ feature name: "nested_scopes"

symtable.h: Add st_nested_scopes slot.  Define flags to track exec and
    import star.

Lib/test/test_scope.py: requires nested scopes

compile.c: Fiddle with error messages.

    Reverse the sense of ste_optimized flag on
    PySymtableEntryObjects.  If it is true, there is an optimization
    conflict.

    Modify get_ref_type to respect st_nested_scopes flags.

    Refactor symtable_load_symbols() into several smaller functions,
    which use struct symbol_info to share variables.  In new function
    symtable_update_flags(), raise an error or warning for import * or
    bare exec that conflicts with nested scopes.  Also, modify handle
    for free variables to respect st_nested_scopes flag.

    In symtable_init() assign st_nested_scopes flag to
    NESTED_SCOPES_DEFAULT (defined in compile.h).

    Add preliminary and often incorrect implementation of
    symtable_check_future().

    Add symtable_lookup() helper for future use.
2001-02-27 04:23:34 +00:00
Fred Drake 3c823aa4b6 Make sure ConfigParser uses .optionxform() consistently; this affects
.has_option(), .remove_option(), and .set().

This closes SF tracker #232913.
2001-02-26 21:55:34 +00:00
Tim Peters ffc215a279 Add __future__.py to std library, + dull test to verify that assignments
therein are of the proper form.
2001-02-26 21:14:49 +00:00
Barry Warsaw c1e100f215 Additional tests for current, PEP described semantics:
- func.__dict__ is None until the first attribute is assigned

- del func.__dict__ is equivalent to func.__dict__ = None

- disallowing assignment to function attribute through unbound method
  (it was always illegal to assign through bound method).

- verifying that setting attribute explicitly on underlying function
  via meth.im_func is okay.
2001-02-26 18:07:26 +00:00
Barry Warsaw 22e4182d60 Describe -s a little more generically. 2001-02-23 18:31:40 +00:00
Tim Peters 0009c4ea59 Whitespace normalization. 2001-02-21 07:29:48 +00:00
Andrew M. Kuchling 9a0f98e0a1 Add test case from bug #124981: zlib decompress of sync-flushed data
fails
2001-02-21 02:17:01 +00:00
Andrew M. Kuchling bc8f72cccc Patch #103854: raises an exception if a non-Attr node is passed to
NamedNodeMap.setNamedItem().  Martin, should I sync the PyXML tree, too,
 or do you want to do it?  (I don't know if you're wrapping the 0.6.4
 release right now.)
2001-02-21 01:30:26 +00:00
Andrew M. Kuchling 8b94b1c74a Added test for patch #103473: test an unquoted cookie value containing '=' 2001-02-21 01:17:54 +00:00
Jeremy Hylton 121b6eb018 SF patch #103749: implicit tuple + default arg 2001-02-19 23:53:42 +00:00
Jeremy Hylton f828e2d737 Add simple section for assert, including assert w/ lambdas 2001-02-19 15:54:52 +00:00
Jeremy Hylton 4779399e9f Add test for syntax error on "x = 1 + 1".
Move check_syntax() function into test_support.
2001-02-19 15:35:26 +00:00
Fredrik Lundh c0c7ee3a65 detect attempts to repeat anchors (fixes bug #130748) 2001-02-18 21:04:48 +00:00
Tim Peters 8ac3627b91 sre_{parse, compile} no longer define __all__. 2001-02-18 14:44:42 +00:00
Fredrik Lundh f2989b22ff - restored 1.5.2 compatibility (sorry, eric)
- removed __all__ cruft from internal modules (sorry, skip)
- don't assume ASCII for string escapes (sorry, per)
2001-02-18 12:05:16 +00:00
Skip Montanaro 78349072f7 removed __all__ from several modules 2001-02-18 03:30:53 +00:00
Tim Peters 0e6d213177 Whitespace normalization. 2001-02-15 23:56:39 +00:00
Skip Montanaro 0de65807e6 bunch more __all__ lists
also modified check_all function to suppress all warnings since they aren't
relevant to what this test is doing (allows quiet checking of regsub, for
instance)
2001-02-15 22:15:14 +00:00
Andrew M. Kuchling 8e6d44eedc Patch #103748 from Toby Dickenson: fix typo in test_zlib that turns one
test case into a no-op because ''.join('hello world') == 'hello world'
2001-02-14 17:46:20 +00:00
Fred Drake cc1f951b4c Test section name using some strange characters, including a backslash
(SF bug #132288).
2001-02-14 15:30:31 +00:00
Tim Peters 60e23f4cfc Change doctest exception example to one whose detail hasn't changed since 1.5.2. 2001-02-14 00:43:21 +00:00
Tim Peters ea4f931cb9 Teach doctest about newer "(most recent call last)" traceback spelling. 2001-02-13 20:54:42 +00:00
Fred Drake 95b96d3941 Added options that use square brackets in their names; this ensures that
GNOME-style internationalized options can be parsed using ConfigParser
(SF bug #131635).

Converted the tests to use test_support.verify() instead of output
comparison to work.
2001-02-12 17:23:20 +00:00
Tim Peters 76c066b103 test_pty started failing on Windows, but if and only if test___all__ was
run first.  Indirectly due to Skip adding check_all("pty") to test___all__:
that caused the expected ImportError due to pty.py trying to import the
non-existent FCNTL to get handled by test___all__, leaving a partial
module object for pty in sys.modules, which caused the later import of
pty via test_pty to succeed.  Then test_tpy died with an AttributeError,
due to trying to access attributes of pty that didn't exist.  regrtest
viewed that as a failure rather than the appropriate "test skipped".
Fixed by deleting partial module objects in test___all__ when test___all__
handles an ImportError.
2001-02-12 03:27:31 +00:00
Skip Montanaro c62c81e013 __all__ for several more modules 2001-02-12 02:00:42 +00:00
Marc-André Lemburg ef0a032883 Patch by Finn Bock to make test_unicode.py work for Jython. 2001-02-10 14:09:31 +00:00
Tim Peters 9ae2148ada Moved SequenceMatcher from ndiff into new std library module difflib.py.
Guido told me to do this <wink>.
Greatly expanded docstrings, and fleshed out with examples.
New std test.
Added new get_close_matches() function for ESR.
Needs docs, but LaTeXification of the module docstring is all it needs.
\CVS: ----------------------------------------------------------------------
2001-02-10 08:00:53 +00:00
Tim Peters 6db54c69a4 Add std test for doctest. 2001-02-10 01:36:47 +00:00
Jeremy Hylton cafd495dfe In O_writelines: Replace use of string.joinfields with "".join. 2001-02-09 23:44:22 +00:00
Jeremy Hylton 11db72a5c3 update to use new symtable interface 2001-02-09 22:57:10 +00:00
Jeremy Hylton 97a01674b2 update test cases for recent compiler changes: exec/import * in nested
functinos and cell vars with */** parameters
2001-02-09 22:56:46 +00:00
Tim Peters 10fb386399 Whitespace normalization. 2001-02-09 20:17:14 +00:00
Eric S. Raymond dbbbaf2696 joinfields -> join. 2001-02-09 17:05:53 +00:00
Eric S. Raymond 83ff749827 String method conversion. 2001-02-09 12:03:45 +00:00
Eric S. Raymond 2846b0ab41 String method conversion.
(This one was trivial -- no actual string. references in it!)
2001-02-09 12:00:47 +00:00
Eric S. Raymond fc170b1fd5 String method conversion. 2001-02-09 11:51:27 +00:00
Eric S. Raymond d8c628bd59 String method conversion.
(This one was trivial -- no actual string. references in it!)
2001-02-09 11:46:37 +00:00
Skip Montanaro 352674d01c a few more __all__ lists 2001-02-07 23:14:30 +00:00
Skip Montanaro cc012e92b2 test for presence of __builtins__ in names before deleting it, enabling this
to work with Jython (ugh! I hate that name!).  This closes patch 103665.
2001-02-07 22:46:55 +00:00
Martin v. Löwis fe28ca09a5 Add xml declaration into toxml testcase. 2001-02-06 01:16:48 +00:00
Skip Montanaro 269b83bc05 added several more __all__ lists 2001-02-06 01:07:02 +00:00
Jeremy Hylton de6024872a Fix test 9 (caught by ?!ng)
Add tests for unbound locals (Nick Mathewson)
2001-02-05 17:35:20 +00:00
Tim Peters d66595fe42 Renamed _testXXX to _testcapiXXX. Jack is my hero -- good call! 2001-02-04 03:09:53 +00:00
Jeremy Hylton 5e7cb240af Add minimal interface to symtable: _symtable module. 2001-02-02 18:24:26 +00:00
Tim Peters 9ea17ac595 Patch derived from Trent's 101162: a Python/C API testing framework.
STILL NEEDS UNIX BUILD CHANGES.
2001-02-02 05:57:15 +00:00
Jeremy Hylton 3faa52ecc4 Allow 'continue' inside 'try' clause
SF patch 102989 by Thomas Wouters
2001-02-01 22:48:12 +00:00
Jeremy Hylton 483638c9a8 Undo recent change that banned using import to bind a global, as per
discussion on python-dev.  'from mod import *' is still banned except
at the module level.

Fix value for special NOOPT entry in symtable.  Initialze to 0 instead
of None, so that later uses of PyInt_AS_LONG() are valid.  (Bug
reported by Donn Cave.)

replace local REPR macros with PyObject_REPR in object.h
2001-02-01 20:20:45 +00:00
Jeremy Hylton 6fe0a82ecb move extra arguments to the back of the new.code() arglist 2001-02-01 19:50:29 +00:00
Fred Drake acfb3f6006 Revise the driver code to be more informative in the final report. 2001-02-01 18:11:29 +00:00
Fred Drake 41deb1efc2 PEP 205, Weak References -- initial checkin. 2001-02-01 05:27:45 +00:00
Moshe Zadka fc3fc337d0 Checking in patch #103478 -- makes popen2 and fork1 tested on BeOS.
Tested for not breaking builds on Linux.
2001-01-30 18:35:32 +00:00
Jeremy Hylton 251ef9666e Fix test for free ref to global. This test should have caught a
recently fixed bug, but it checked for the wrong answer.
2001-01-30 01:26:53 +00:00
Jeremy Hylton ac25a38841 add test for illegal imports 2001-01-30 01:25:56 +00:00
Marc-André Lemburg fde66e1bcc Fixed .capitalize() method of Unicode objects to work like the
corresponding string method. Added tests for this too.

Patch written by Marc-Andre Lemburg. Copyright assigned to Guido van Rossum.
2001-01-29 11:14:16 +00:00
Moshe Zadka 497671e094 The one thing I love more then writing code is deleting code.
* Removed func_hash and func_compare, so they can be treated as immutable
  content-less objects (address hash and comparison)
* Added tests to that affect to test_funcattrs (also testing func_code
  is writable)
* Reverse meaning of tests in test_opcodes which checked identical code
  gets identical functions
2001-01-29 06:21:17 +00:00
Skip Montanaro 080c99745f added several more urlencode test cases - part of patch 103391 2001-01-28 21:12:22 +00:00
Fred Drake 64d42c5bb1 Added tests for new signature of new.instance().
Use test_support.verify() where applicable.
2001-01-28 03:57:39 +00:00
Martin v. Löwis 2bcb32372c Except HierarchyRequestErr instead of TypeError. 2001-01-27 09:17:55 +00:00
Jeremy Hylton 619eea6821 PEP 227 implementation
test_new: new.code() noew takes two more arguments
test_grammer: Add a bunch of test cases for lambda (not really PEP 227 related)
2001-01-25 20:12:27 +00:00
Jeremy Hylton 4588c78faf PEP 227 implementation
New tests cases for nested scopes.
2001-01-25 20:11:23 +00:00
Jeremy Hylton 92e9f29aec add extra tests to verify that co_varnames is being set up properly
also normalize checks for syntax errors and delete commented out
definition of verify.
2001-01-25 17:03:37 +00:00
Skip Montanaro 03d9014992 added a few more __all__ lists
test___all__.py: fail silently in check_all if the module can't be imported
2001-01-25 15:29:22 +00:00
Guido van Rossum 42756df91c Fix the test output, now that escapes in repr() of string and Unicode
are different (Ping didn't test this).
2001-01-24 21:49:57 +00:00
Guido van Rossum 0fc8b74fc5 Fix the test output, now that escapes in repr() of string and Unicode
are different (Ping couldn't test this).
2001-01-24 21:46:18 +00:00
Ka-Ping Yee fa004ad36c Show '\011', '\012', and '\015' as '\t', '\n', '\r' in strings.
Switch from octal escapes to hex escapes for other nonprintable characters.
2001-01-24 17:19:08 +00:00
Fredrik Lundh 06d126803c Move uchhash functionality into unicodedata (after the recent
crop of changes, the files are small enough to do this).  Also
adds "name" and "lookup" functions to unicodedata.
2001-01-24 07:59:11 +00:00
Skip Montanaro 17ab123cf1 a few more modules get __all__ 2001-01-24 06:27:27 +00:00
Barry Warsaw 24f3acab3b It's "gopherlib" not "gopher". 2001-01-24 04:13:02 +00:00
Skip Montanaro 2dd4276559 added a few more __all__ lists
fixed typo in ihooks docstring
2001-01-23 15:35:05 +00:00
Tim Peters f87d857080 Restore alphabetic order. Also try to import rlcompleter and curses, but
don't fail if they're not available.
2001-01-23 09:50:30 +00:00
Jeremy Hylton 578ceee042 Add simple test of list comprehension that uses a name that isn't
otherwise used in the same code block.  (Not sure this is the right
place, but there is no test_list_comprehensions.py.)
2001-01-23 01:51:40 +00:00
Guido van Rossum d0f5e70016 - Use "exec ... in dict" to avoid having to walk on eggshells; locals
no don't have to start with underscore.

- Add spaces after commas in argument lists.

- Only test dbhash if bsddb can be imported.  (Wonder if there are
  more like this?)
2001-01-22 23:37:04 +00:00
Tim Peters 763cb0aa44 Typo repair. 2001-01-22 22:43:35 +00:00
Tim Peters e935816164 Reorganize pickle/cPickle testing so the tests pass regardless of the order
they're run.
2001-01-22 22:05:20 +00:00
Fred Drake d74804db41 The "user" module cannot reasonably be tested. Moved to the end (and
commented it out), and added an explanation as to *why*.

Added period to docstring.
2001-01-22 19:38:37 +00:00
Guido van Rossum 7f9b5e014b OK, changed my mind once more on this. The comparison hierarchy is
now

    None < all numeric types < all other types

so that once again

    map(max, Squares(3), Squares(2))

equals

    [0, 1, 4]
2001-01-22 19:30:07 +00:00
Guido van Rossum d9bae8b95a Numeric-smelling objects now once again compare smaller than
non-numeric ones, so 4 < None again in the 'map' test.
2001-01-22 16:01:24 +00:00
Guido van Rossum f317a18a4a Finn Bock (SF patch #103345): Avoid outdated exec form in
test_class.py.
2001-01-22 14:51:41 +00:00
Tim Peters d304f44906 Patch #103343: Allow the important test_pkg to succeed under Jython. 2001-01-21 19:51:53 +00:00
Tim Peters 08dabf0a73 Patch #103344: Sort dicts from extcall for easier comparison with Jython. 2001-01-21 18:52:02 +00:00
Tim Peters dfc538acae Whitespace normalization. 2001-01-21 04:49:16 +00:00
Skip Montanaro eccd02a40d more __all__ updates 2001-01-20 23:34:12 +00:00
Skip Montanaro e78b92a062 added some tests for urlencode 2001-01-20 20:22:30 +00:00
Skip Montanaro e99d5ea25b added __all__ lists to a number of Python modules
added test script and expected output file as well
this closes patch 103297.
__all__ attributes will be added to other modules without first submitting
a patch, just adding the necessary line to the test script to verify
more-or-less correct implementation.
2001-01-20 19:54:20 +00:00
Skip Montanaro c955f89225 docstring typo 2001-01-20 19:12:54 +00:00
Fredrik Lundh f60560626c Better error message if ucnhash cannot be found (obscure attribute
errors aren't that helpful), or doesn't contain what's expected from
it.  Also tweaked the test script so it compiles even if ucnhash is
missing.
2001-01-20 11:15:25 +00:00
Guido van Rossum 0a5f91f1d9 Now that Marc-Andre has retracted unistr(), remove the tests. 2001-01-19 21:57:52 +00:00
Guido van Rossum a8e14d4d03 Use a saner test filename, to work on Windows. 2001-01-19 21:06:50 +00:00
Barry Warsaw 2e9b396740 Add some regression tests of coredump bugs in funcobject.c 2.31. Also
added a test of a coredump that would occur when del'ing
func_defaults (put here for convenience).
2001-01-19 19:55:12 +00:00
Guido van Rossum a1374e429b Change verify() function to raise TestFailed, not AssertionError.
(I realize that I didn't really test this, because all the tests
succeed, so verify() never raised an AssertionError -- but the test
suite still succeeds, so I'm not too worried.)
2001-01-19 19:01:56 +00:00
Fredrik Lundh 2acb54a194 improved the ucnhash test a bit 2001-01-19 11:13:46 +00:00
Fredrik Lundh ee865c64da added "getcode" and "getname" methods to the ucnhash module (they're
probably more useful for the test code than for any applications, but
one never knows...)
2001-01-19 11:00:42 +00:00
Fredrik Lundh 0fdb90cafe refactored the unicodeobject/ucnhash interface, to hide the
implementation details inside the ucnhash module.

also cleaned up the unicode copyright blurb a little; Secret Labs'
internal revision history isn't that interesting...
2001-01-19 09:45:02 +00:00