Commit Graph

1965 Commits

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