Commit Graph

6516 Commits

Author SHA1 Message Date
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
Guido van Rossum dbfb12148d On Windows, make sure SocketType is the same as socket. (SF bug
598097)
2002-08-22 17:31:16 +00:00
Guido van Rossum dc61cdf6c0 Change the binary operators |, &, ^, - to return NotImplemented rather
than raising TypeError when the other argument is not a BaseSet.  This
made it necessary to separate the implementation of e.g. __or__ from
the union method; the latter should not return NotImplemented but
raise TypeError.  This is accomplished by making union(self, other)
return self|other, etc.; Python's binary operator machinery will raise
TypeError.

The idea behind this change is to allow other set implementations with
an incompatible internal structure; these can provide union (etc.) with
standard sets by implementing __ror__ etc.

I wish I could do this for comparisons too, but the default comparison
implementation allows comparing anything to anything else (returning
false); we don't want that (at least the test suite makes sure
e.g. Set()==42 raises TypeError).  That's probably fine; otherwise
other set implementations would be constrained to implementing a hash
that's compatible with ours.
2002-08-22 17:23:33 +00:00
Fred Drake 61cf4407be Added a main() function and support to run this module as a script.
Closes SF feature request #588768.
2002-08-21 20:56:21 +00:00
Fred Drake a96f1a3c08 Refactor: Remove some code that was obsoleted when this module was
changed to use universal newlines.

           Remove all imports from the compile() function; these are
           now done at the top of the module ("Python normal form"),
           and define a helper based on the platform instead of
           testing the platform in the compile() function.
2002-08-21 20:23:22 +00:00
Raymond Hettinger d9c9151a53 Now that __init__ transforms set elements, we know that all of the
elements are hashable, so we can use dict.update() or dict.copy()
for a C speed Set.copy().
2002-08-21 13:20:51 +00:00
Raymond Hettinger c3e61e5c52 Add regression test for proper construction of sets of sets. 2002-08-21 06:38:44 +00:00
Raymond Hettinger 80d21af614 Sped ._update() method by factoring try/except out of the inner loop. 2002-08-21 04:12:03 +00:00
Guido van Rossum 9f87293bf5 Ouch. The test suite *really* needs work!!!!! There were several
superficial errors and one deep one that aren't currently caught.  I'm
headed for bed after this checkin.

- Fixed several typos introduced by Raymond Hettinger (through
  cut-n-paste from my template): it's _as_temporarily_immutable, not
  _as_temporary_immutable, and moreover when the element is added, we
  should use _as_immutable.

- Made the seq argument to ImmutableSet.__init__ optional, so we can
  write ImmutableSet() to create an immutable empty set.

- Rename the seq argument to Set and ImmutableSet to iterable.

- Add a Set.__hash__ method that raises a TypeError.  We inherit a
  default __hash__ implementation from object, and we don't want that.
  We can then catch this in update(), so that
  e.g. s.update([Set([1])]) will transform the Set([1]) to
  ImmutableSet([1]).

- Added the dance to catch TypeError and try _as_immutable in the
  constructors too (by calling _update()).  This is needed so that
  Set([Set([1])]) is correctly interpreted as
  Set([ImmutableSet([1])]).  (I was puzzled by a side effect of this
  and the inherited __hash__ when comparing two sets of sets while
  testing different powerset implementations: the Set element passed
  to a Set constructor wasn't transformed to an ImmutableSet, and then
  the dictionary didn't believe the Set found in one dict it was the
  same as ImmutableSet in the other, because the hashes were
  different.)

- Refactored Set.update() and both __init__() methods; moved the body
  of update() into BaseSet as _update(), and call this from __init__()
  and update().

- Changed the NotImplementedError in BaseSet.__init__ to TypeError,
  both for consistency with basestring() and because we have to use
  TypeError when denying Set.__hash__.  Together those provide
  sufficient evidence that an unimplemented method needs to raise
  TypeError.
2002-08-21 03:20:44 +00:00
Guido van Rossum 26588222b3 Add Raymond H to the list of authors; add some XXX comments about
possible API improvements.
2002-08-21 02:44:04 +00:00
Raymond Hettinger 43db0d6a2c Fast size check for sub/super set tests 2002-08-21 02:22:08 +00:00
Raymond Hettinger de6d697987 Optimize try/except ordering in sets.py.
Gains a 5:1 speed-up for membership testing by
handling the most common case first (the case
where the element is hashable).

Closes SF Patch 597444.
2002-08-21 01:35:29 +00:00
Raymond Hettinger ede3a0da8b Minor typo 2002-08-20 23:34:01 +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 5033b36c44 Move __init__ from BaseSet into Set and ImmutableSet. This causes a
tiny amount of code duplication, but makes it possible to give BaseSet
an __init__ that raises an exception.
2002-08-20 21:38:37 +00:00
Guido van Rossum e3ec296df8 Typo repair. Please include in any backports. 2002-08-20 20:07:10 +00:00
Guido van Rossum 290f1870f1 Add a note reminding the reader that sets are not sequences. I
received feedback that was based in the misunderstanding that sets
were sequences.
2002-08-20 20:05:23 +00:00
Guido van Rossum 0bd7832285 SF patch 595846 by Brett Cannon: Update environ for CGIHTTPServer.py
This patch causes CGIHTTPServer to update os.environ regardless of how
it tries to handle calls (fork, popen*, etc.).

Backport bugfix candidate.
2002-08-20 19:55:06 +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
Barry Warsaw 4d5ef6aed6 Bump version number to 2.3 2002-08-20 14:51:34 +00:00
Barry Warsaw 3328136e3c Added tests for SF patch #597593, syntactically invalid Content-Type: headers. 2002-08-20 14:51:10 +00:00
Barry Warsaw f36d804b3b get_content_type(), get_content_maintype(), get_content_subtype(): RFC
2045, section 5.2 states that if the Content-Type: header is
syntactically invalid, the default type should be text/plain.
Implement minimal sanity checking of the header -- it must have
exactly one slash in it.  This closes SF patch #597593 by Skip, but in
a different way.

Note that these methods used to raise ValueError for invalid ctypes,
but now they won't.
2002-08-20 14:50:09 +00:00
Barry Warsaw dfea3b3963 _dispatch(): Use get_content_maintype() and get_content_subtype() to
get the MIME main and sub types, instead of getting the whole ctype
and splitting it here.   The two more specific methods now correctly
implement RFC 2045, section 5.2.
2002-08-20 14:47:30 +00:00
Barry Warsaw b404bb7813 test_three_lines(): Test case reported by Andrew McNamara. Works in
email 2.2 but fails in email 1.0.
2002-08-20 12:54:07 +00:00
Guido van Rossum 0b650d7565 Fix typo in __slots__ of ImmutableSet. 2002-08-19 16:29:58 +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
Raymond Hettinger f2e45dd9dd Modify splituser() method to allow an @ in the userinfo field.
Jeremy reported that this is not allowed by RFC 2396; however,
other tools support unescaped @'s so we should also.

Apply SF patch 596581 closing bug 581529.
2002-08-18 20:08:56 +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 9146f27b77 SF bug 594996: OverflowError in random.randrange
Loosened the acceptable 'start' and 'stop' arguments so that any
Python (bounded) ints can be used.  So, e.g., randrange(-sys.maxint-1,
sys.maxint) no longer blows up.
2002-08-16 03:41:39 +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
Jeremy Hylton 92bb6e7b96 Docstring nits: The module is neither proposed nor new. 2002-08-14 19:25:42 +00:00
Guido van Rossum 54df53a352 More changes of DeprecationWarning to FutureWarning. 2002-08-14 18:38:27 +00:00