Commit Graph

9683 Commits

Author SHA1 Message Date
Raymond Hettinger 7b46f6b2a5 Add tests for syntax errors. 2004-09-30 22:29:03 +00:00
Raymond Hettinger 49c522be80 Expand scope to include general mapping protocol tests.
Many of these tests are redundant, but this will ensure
that the mapping protocols all stay in sync.
Also, added a test for dictionary subclasses.
2004-09-30 15:07:29 +00:00
Walter Dörwald 59b23e8b80 Add missing test_dict.py from patch #736962. 2004-09-30 13:46:00 +00:00
Raymond Hettinger 5ea7e31076 Improve test coverage. 2004-09-30 07:47:20 +00:00
Raymond Hettinger ff5dc0ee77 Improve test coverage. 2004-09-29 11:40:50 +00:00
Raymond Hettinger bcab2b25f9 Improve test coverage. 2004-09-29 08:03:17 +00:00
Edward Loper 7d88a58e85 Reverted the addition of a NORMALIZE_NUMBERS option, per Tim Peter's
request.  Tim says that "correct 'fuzzy' comparison of floats cannot
be automated."  (The motivation behind adding the new option
was verifying interactive examples in Python's latex documentation;
several such examples use numbers that don't print consistently on
different platforms.)
2004-09-28 05:50:57 +00:00
Raymond Hettinger 4cda01e260 * Increase test coverage.
* Have groupby() be careful about decreffing structure members.
2004-09-28 04:45:28 +00:00
Edward Loper aec3c9b54f Added a new NORMALIZE_NUMBERS option, which causes number literals in
the expected output to match corresponding number literals in the
actual output if their values are equal (to ten digits of precision).
2004-09-28 04:29:57 +00:00
Raymond Hettinger 6429a4727e Use Py_CLEAR(). Add unrelated test. 2004-09-28 01:51:35 +00:00
Raymond Hettinger 855d9a985b Plug a leak and beef-up test coverage. 2004-09-28 00:03:54 +00:00
Raymond Hettinger 630e5355b5 Rename test for comparision errors. 2004-09-27 23:11:35 +00:00
Raymond Hettinger 63251781d1 Beef-up tests for greater coverage and refcount checking. 2004-09-27 22:48:40 +00:00
Armin Rigo 9f90439817 Patch #1011240: SystemError generated by struct.pack('P', 'foo'). 2004-09-27 19:27:51 +00:00
Armin Rigo b562bc672b Trivial bug fix: deque == [] is not a good way to check if a deque is empty. 2004-09-27 17:49:00 +00:00
Raymond Hettinger ffdb8bb99c Use floor division operator. 2004-09-27 15:29:05 +00:00
Raymond Hettinger 4837a223ee Use floor division operator. 2004-09-27 14:23:40 +00:00
Edward Loper 498a1868e7 - Added a "parser" option to testfile() and DocFileTest(). 2004-09-27 03:42:58 +00:00
Raymond Hettinger aa241e0149 Checkin Tim's fix to an error discussed on python-dev.
Also, add a testcase.

Formerly, the list_extend() code used several local variables to remember
its state across iterations.  Since an iteration could call arbitrary
Python code, it was possible for the list state to be changed.  The new
code uses dynamic structure references instead of C locals.  So, they
are always up-to-date.

After list_resize() is called, its size has been updated but the new
cells are filled with NULLs.  These needed to be filled before arbitrary
iteration code was called; otherwise, that code could attempt to modify
a list that was in a semi-invalid state.  The solution was to change
the ob->size field back to a value reflecting the actual number of valid
cells.
2004-09-26 19:24:20 +00:00
Raymond Hettinger 55593c3ef5 Make the regex pattern easier to read, understand, and modify
by factoring out the common prefix (the delimiter).
2004-09-26 18:56:44 +00:00
Tim Peters 3afaaf2487 Removed debug_script from the public API: no docs, not public. I'm in
the process of writing docs for the other "missing" debug support
functions.
2004-09-26 03:50:06 +00:00
Tim Peters 9d02a7cfa0 Add set_unittest_reportflags() to the public API. Docs will follow
"soon", after I repair the LaTeX I somehow damaged.
2004-09-26 01:50:24 +00:00
Tim Peters 261b28aac6 Removed two undocumented unittest support classes, and one undocumented
unittest support function, from the public interface.  If they're not
documented, they shouldn't be public.
2004-09-26 01:24:23 +00:00
Tim Peters 48983fc484 Removed most of the module docstring. There's too much to explain now,
and the LaTeX docs are in increasingly good shape.
2004-09-25 02:41:28 +00:00
Tim Peters 5a59d88e89 Whitespace normalization. 2004-09-24 23:16:41 +00:00
Johannes Gijsbers 3981511070 Port test_unpack to doctest (patch #736962). 2004-09-24 21:36:52 +00:00
Neil Schemenauer 6bc937cfd2 Add yet more tests for buffer(). 2004-09-24 19:18:42 +00:00
Neil Schemenauer 29302a7867 Add a few more tests for the buffer() object. 2004-09-24 15:35:15 +00:00
Vinay Sajip b2635b2f71 Added log() function 2004-09-24 11:45:52 +00:00
Vinay Sajip 02dd994adf Added exception handling during handler initialization in fileConfig() 2004-09-24 11:45:13 +00:00
Tim Peters 1cc37380b2 Whitespace normalization. 2004-09-24 04:36:47 +00:00
Raymond Hettinger 596ba4d89e Granted Noam Raphael's request for minor improvements to the re module and
its documentation.

* Documented that the compiled re methods are supposed to be more full
  featured than their simpilified function counterparts.

* Documented the existing start and stop position arguments for the
  findall() and finditer() methods of compiled regular expression objects.

* Added an optional flags argument to the re.findall() and re.finditer()
  functions.  This aligns their API with that for re.search() and
  re.match().
2004-09-24 03:41:05 +00:00
Tim Peters 307fa78107 SF bug #513866: Float/long comparison anomaly.
When an integer is compared to a float now, the int isn't coerced to float.
This avoids spurious overflow exceptions and insane results.  This should
compute correct results, without raising spurious exceptions, in all cases
now -- although I expect that what happens when an int/long is compared to
a NaN is still a platform accident.

Note that we had potential problems here even with "short" ints, on boxes
where sizeof(long)==8.  There's #ifdef'ed code here to handle that, but
I can't test it as intended.  I tested it by changing the #ifdef to
trigger on my 32-bit box instead.

I suppose this is a bugfix candidate, but I won't backport it.  It's
long-winded (for speed) and messy (because the problem is messy).  Note
that this also depends on a previous 2.4 patch that introduced
_Py_SwappedOp[] as an extern.
2004-09-23 08:06:40 +00:00
Raymond Hettinger 4533f1fb7f Improve three recipes in the itertools docs. 2004-09-23 07:27:39 +00:00
Raymond Hettinger 513c8bd6f2 Arghh, checked in wrong draft. Replacing with correct one. 2004-09-23 07:00:47 +00:00
Raymond Hettinger 0336e1fe8c Use local variables in StringIO.write().
Makes it easier on the eyes and a bit more snappy.
2004-09-23 06:43:25 +00:00
Phillip J. Eby 7ec642a4d2 Fix for SF bug #1029475 : reload() doesn't work with PEP 302 loaders. 2004-09-23 04:37:36 +00:00
Raymond Hettinger 2c31a058eb SF patch #1031667: Fold tuples of constants into a single constant
Example:
>>> import dis
>>> dis.dis(compile('1,2,3', '', 'eval'))
  0           0 LOAD_CONST               3 ((1, 2, 3))
              3 RETURN_VALUE
2004-09-22 18:44:21 +00:00
Raymond Hettinger ce96d8b684 Bug #1030125: rfc822 __iter__ problem
Add iteration support to the Message class.
2004-09-22 17:17:32 +00:00
Vinay Sajip b9591174df Added getLoggerClass() 2004-09-22 12:39:26 +00:00
Edward Loper a2fc7ec80a - Minor docstring fixes.
- Simplified code to find names for file-based tests.
2004-09-21 03:24:24 +00:00
Edward Loper 4ae900f43b - Changed SampleClass docstrings to test docstring parsing a little
more thouroughly.
2004-09-21 03:20:34 +00:00
Tim Peters bab3e99689 Whitespace normalization. 2004-09-20 19:52:34 +00:00
Raymond Hettinger 61656203cd Import no longer needed. 2004-09-20 18:08:31 +00:00
Skip Montanaro 13dea5a42b Raymond reminded me to use DSU key 2004-09-20 16:43:30 +00:00
Skip Montanaro 41f89a4f3d Sort classes by fully qualified name. In the common case where you are
displaying a set of classes from one module it doesn't matter, but if you
are displaying a large class tree from multiple modules it improves the
display to sort by module.name.
2004-09-20 15:40:38 +00:00
Edward Loper 052d0cd291 - Added "testfile" function, a simple function for running & verifying
all examples in a given text file. (analagous to "testmod")
- Minor docstring fixes.
- Added module_relative parameter to DocTestFile/DocTestSuite, which
  controls whether paths are module-relative & os-independent, or
  os-specific.
2004-09-19 17:19:33 +00:00
Raymond Hettinger 636a6b100f SF patch #1020845: Decimal performance enhancements
(Contributed by Nick Coghlan.)

Various code cleanups and optimizations (saves about 40% on testsuite
execution time and on the telco benchmark).

* caches results of various operations on self (esp. checks for being
  a special value).

* _WorkRep now uses ints and longs for intermediate computations.
2004-09-19 01:54:09 +00:00
Edward Loper 0273f5b6b2 In DocFileTest:
- Fixed bug in handling of absolute paths.
  - If run from an interactive session, make paths relative to the
    directory containing sys.argv[0] (since __main__ doesn't have
    a __file__ attribute).
2004-09-18 20:27:04 +00:00
Martin v. Löwis 725f8c83a2 Patch #1021596: Check for None to determine whether _urandomfd is
uninitialized.
2004-09-18 16:07:58 +00:00
Martin v. Löwis b0c670ce39 Convert boolean results back to strings. Fixes #807871.
Will backport to 2.3.
2004-09-18 16:01:23 +00:00
Martin v. Löwis f3c5611fef Patch #1029061: Always extract member names from the tarinfo. 2004-09-18 09:08:52 +00:00
Martin v. Löwis 39a317890f Patch #1025790: Add status code constants to httplib. 2004-09-18 09:03:49 +00:00
Barry Warsaw 17cb60083c At the cost of a modest (but useful in its own right) change in the semantics
of the Template.delimiter attribute, we make use of the delimiter in the
escaped group, and in the safe_substitute() method more robust.

Now, .delimiter should be the unescaped delimiter literal, e.g. '$' or '&', or
whatever.  The _TemplateMetaclass will re.escape() this value when it builds
the pattern.
2004-09-18 00:06:34 +00:00
Sean Reifschneider 6011a3c874 SF Patch 1022011: Add a command-line argument --no-autoreq, which sets the
"AutoReq: 0" to disable automatic dependency searching.
2004-09-17 08:34:12 +00:00
Sean Reifschneider 57a6a41e54 SF Patch 1022003: Change bdist_rpm _topdir to use
os.path.abspath(self.rpm_base) instead of os.getcwd() + '/' + self.rpm_base
2004-09-17 08:23:22 +00:00
Tim Peters 528ca53b74 SF bug #1028306: date-datetime comparison
Treat comparing a date to a datetime like a mixed-type comparison.
2004-09-16 01:30:50 +00:00
Tim Peters c74298a72b Whitespace normalization. 2004-09-16 00:09:19 +00:00
Brett Cannon 0a1af4aeb0 Remove tabs. 2004-09-15 23:26:23 +00:00
Martin v. Löwis 9996828caa Patch #1026986: Add OpenBSD 3.5 and 3.6 to list of broken systems. 2004-09-15 06:02:54 +00:00
Martin v. Löwis 74a249e1a9 Strip square brackets from IPv6 address. 2004-09-14 21:45:36 +00:00
Skip Montanaro cae14d2714 missed the obvious test case and corresponding fix 2004-09-14 17:55:21 +00:00
Skip Montanaro 10e6e0e61a Search from the end of the host/port combination to find the colon which
separates ip address from the port to accommodate ipv6 addresses.
2004-09-14 16:32:02 +00:00
Walter Dörwald 065a32f550 Make the hint about the None default less ambiguous. 2004-09-14 09:45:10 +00:00
Walter Dörwald 782afc5927 Enhance the docstrings for unicode.split() and string.split()
to make it clear that it is possible to pass None as the
separator argument to get the default "any whitespace" separator.
2004-09-14 09:40:45 +00:00
Raymond Hettinger 6d191113a6 Fix small bugs in Template code.
* The parameterization of "delimiter" was incomplete.
* safe_substitute's code for braced delimiters should only be executed
  when braced is not None.
* Invalid pattern group names now raise a ValueError.  Formerly, the
  convert code would fall off the end and improperly return None.

Beefed-up tests.

* Test delimiter override for all paths in substitute and safe_substitute.
* Alter unittest invocation to match other modules (now it itemizes the
  tests as they are run).
2004-09-14 02:34:08 +00:00
Raymond Hettinger 23f1241dc6 SF #1027105: HardwareRandom should be renamed OSRandom
Renamed the new generator at Trevor's recommendation.
The name HardwareRandom suggested a bit more than it
delivered (no radioactive decay detectors or such).
2004-09-13 22:23:21 +00:00
Barry Warsaw 3e773fb622 The 4th group is now 'invalid' instead of 'bogus'. 2004-09-13 20:53:27 +00:00
Barry Warsaw b5c6b5bfe8 Raymond's good suggestion to re-order the tests in the convert() helper so the
most common paths are tested first.  Also, that 'invalid' is better than
'bogus'.
2004-09-13 20:52:50 +00:00
Barry Warsaw b6234a95c1 substitute(), safe_substitute(): Paul Moore provides a better hack for dealing
with positional arguments.
2004-09-13 15:25:15 +00:00
Barry Warsaw c7cd20c8c6 Added a test for # positional arguments > 1. 2004-09-13 15:24:43 +00:00
Tim Peters 958cc89037 exclude_empty: make the default True for DocTestFinder, and introduce it
with default False for testmod().  The real point of introducing this was
so that output from doctest.master.summarize() would be the same as in
2.3, and doctest.master in 2.4 is a backward-compatability hack used only
by testmod().
2004-09-13 14:53:28 +00:00
Barry Warsaw 302bd589ad Add tests for keyword arguments and combining mapping and keyword arguments. 2004-09-13 14:35:59 +00:00
Barry Warsaw 46b629c101 Accepted Raymond's patch to combine mapping and keyword arguments, with slight
modification.  Also, renamed the positional argument to '__mapping' to further
reduce the chance of duplicate keyword arguments.
2004-09-13 14:35:04 +00:00
Edward Loper 32ddbf7fab Added new parameter exclude_empty to DocTestFinder.__init__, which
controls whether tests are included for objects with empty docstrings.
Defaults to True, to match the behavior of Python 2.3.
2004-09-13 05:47:24 +00:00
Tim Peters c56847878e DocTestFinder._find(): for tests derived from a module __test__ global,
doctest always promised to stick "__test__" in the name.  That got
broken.  Now it's fixed again.
2004-09-13 01:07:12 +00:00
Tim Peters 82076ef194 Reluctantly, rehabilitate doctest.master. 2004-09-13 00:52:51 +00:00
Tim Peters 9661f9ab4f Tester.run___test__(): This couldn't possibly work at all. I'm afraid
the "backward compatibility" here was a joke.
2004-09-12 22:45:17 +00:00
Tim Peters 4be7a92f7f Tester.__init__(): this couldn't possibly work when a module argument
was passed.
2004-09-12 22:39:46 +00:00
Tim Peters 0e9980f75a Whitespace normalization. 2004-09-12 03:49:31 +00:00
Johannes Gijsbers d60e92a48d Document not-completely-obvious behavior in a test. 2004-09-11 21:26:21 +00:00
Tim Peters 17b56379e1 Recover from inspect.getmodule() changes. It returns a module for
functions and methods now, including functions defined inside doctests
in test_doctest.py's recursive doctest'ing.
2004-09-11 17:33:27 +00:00
Johannes Gijsbers 9324526a76 Use __module__ attribute when available instead of using isclass() predicate
(functions and methods have grown the __module__ attribute too). See bug #570300.
2004-09-11 15:53:22 +00:00
Barry Warsaw f43e8bd7b4 Template: remove __slots__ since that interferes with the ability to mix in
Template and unicode classes.
2004-09-10 18:30:42 +00:00
Andrew M. Kuchling 55be9eab38 Typo fix: 'comparisions' is not a word 2004-09-10 12:59:54 +00:00
Martin v. Löwis 23c48a12d9 Patch #808120: Add --force-arch=ARCH to bdist_rpm.py. 2004-09-10 06:32:54 +00:00
Martin v. Löwis 641d64812c Patch #808115: Add script support to bdist_rpm.py. 2004-09-10 06:25:01 +00:00
Raymond Hettinger 1f7d6a633f __slots__ went missing from Template. 2004-09-10 06:21:22 +00:00
Barry Warsaw 12827c1fa9 Many updates to PEP 292 templates. Summary:
- Template no longer inherits from unicode.

- SafeTemplate is removed.  Now Templates have both a substitute() and a
  safe_substitute() method, so we don't need separate classes.  No more
  __mod__() operator.

- Adopt Tim Peter's idea for giving Template a metaclass, which makes the
  delimiter, the identifier pattern, or the entire pattern easy to override
  and document, while retaining efficiency of class-time compilation of the
  regexp.

- More informative ValueError messages which will help a user narrow down the
  bogus delimiter to the line and column in the original string (helpful for
  long triple quoted strings).
2004-09-10 03:08:08 +00:00
Fred Drake 583359ed2e clean up the API a little; exceptions are defined by this module
(needs documentation)
2004-09-09 02:24:13 +00:00
Fred Drake 58ae830fd0 add name that should be considered public to __all__ 2004-09-09 01:49:58 +00:00
Fred Drake 49b4d19172 remove unnecessary override of base class method 2004-09-08 22:58:36 +00:00
Fred Drake 75d9a62fe0 add tests that make sure buffer boundaries are handled properly for SGML comments
(see SF patch #901369)
2004-09-08 22:57:01 +00:00
Brett Cannon 85ae1a69b6 Remove usage of locale.getlocale in favor or setlocale(LC_NUMERIC, None) .
Also added a comment about why the code is bother to see what setlocale thinks
the set locale is.

Closes bug #1023798.
2004-09-08 02:02:41 +00:00
Walter Dörwald 69652035bc SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
decoding incomplete input (when the input stream is temporarily exhausted).
codecs.StreamReader now implements buffering, which enables proper
readline support for the UTF-16 decoders. codecs.StreamReader.read()
has a new argument chars which specifies the number of characters to
return. codecs.StreamReader.readline() and codecs.StreamReader.readlines()
have a new argument keepends. Trailing "\n"s will be stripped from the lines
if keepends is false. Added C APIs PyUnicode_DecodeUTF8Stateful and
PyUnicode_DecodeUTF16Stateful.
2004-09-07 20:24:22 +00:00
Jeremy Hylton 8f00a24229 Remove debugging print (not triggered by test suite) and add XXX comment about how the code should raise a SyntaxError. 2004-09-07 15:36:48 +00:00
Jeremy Hylton 566d934745 compiler.transformer: correct lineno attribute when possible
SF patch #1015989

The basic idea of this patch is to compute lineno attributes for all AST nodes.  The actual
implementation lead to a lot of restructing and code cleanup.

The generated AST nodes now have an optional lineno argument to constructor.  Remove the
top-level asList(), since it didn't seem to serve any purpose.  Add an __iter__ to ast nodes.
Use isinstance() instead of explicit type tests.

Change transformer to use the new lineno attribute, which replaces three lines of code with one.
Use universal newlines so that we can get rid of special-case code for line endings.  Use
lookup_node() in a few more frequently called, but simple com_xxx methods().  Change string
exception to class exception.
2004-09-07 15:28:01 +00:00
Brett Cannon 2ad68e69b9 Ported test__locale to unittest. 2004-09-06 23:30:27 +00:00
Raymond Hettinger 658717ed11 SF #1022953: binascii.a2b_hqx("") raises SystemError
Several functions adopted the strategy of altering a full lengthed
string copy and resizing afterwards.  That would fail if the initial
string was short enough (0 or 1) to be interned.  Interning precluded
the subsequent resizing operation.

The solution was to make sure the initial string was at least two
characters long.

Added tests to verify that all binascii functions do not crater when
given an empty string argument.
2004-09-06 22:58:37 +00:00
Raymond Hettinger 8158e84930 Fix erroneous docstring comment. 2004-09-06 07:04:09 +00:00