Commit Graph

33 Commits

Author SHA1 Message Date
Nick Coghlan d2e0938362 Issue #3781: Final cleanup of warnings.catch_warnings and its usage in the test suite. Closes issue w.r.t. 2.6 (R: Brett Cannon) 2008-09-11 12:11:06 +00:00
Brett Cannon 672237dc6c warnings.catch_warnings() now returns a list or None instead of the custom
WarningsRecorder object. This makes the API simpler to use as no special object
must be learned.

Closes issue 3781.
Review by Benjamin Peterson.
2008-09-09 00:49:16 +00:00
Brett Cannon 32476fc5a8 Deprecate bsddb for removal in Python 3.0.
Closes issue 3776.
Review by Nick Coghlan.
2008-09-05 18:33:51 +00:00
Brett Cannon 1eaf0742d8 Move test.test_support.catch_warning() to the warnings module, rename it
catch_warnings(), and clean up the API.

While expanding the test suite, a bug was found where a warning about the
'line' argument to showwarning() was not letting functions with '*args' go
without a warning.

Closes issue 3602.
Code review by Benjamin Peterson.
2008-09-02 01:25:16 +00:00
Nick Coghlan 38469e2719 Make test.test_support.catch_warnings more robust as discussed on python-dev. Also add explicit tests for itto test_warnings. 2008-07-13 12:23:47 +00:00
Brett Cannon dea1b5653f warnings.warn_explicit() did not have the proper TypeErrors in place to prevent
bus errors or SystemError being raised. As a side effect of fixing this, a bad
DECREF that could be triggered when 'message' and 'category' were both None was
fixed.

Closes issue 3211. Thanks JP Calderone for the bug report.
2008-06-27 00:31:13 +00:00
Georg Brandl 885982283e Fix another "refleak" by clearing the filters after test. 2008-05-14 07:18:22 +00:00
Benjamin Peterson d295032910 Fix logic error in Python/_warnings.c and add a test to verify 2008-05-06 22:18:11 +00:00
Brett Cannon e3dcb01bfc Fix a bug in the handling of the stacklevel argument in warnings.warn() where
the stack was being unwound by two levels instead of one each time.
2008-05-06 04:37:31 +00:00
Brett Cannon 8a232cc385 Add a DeprecationWarning for when warnings.showwarning() is set to a function
that lacks support for the new 'line' argument.
2008-05-05 05:32:07 +00:00
Brett Cannon 64a4bbeb25 Fix the C implementation of 'warnings' to infer the filename of the module that
raised an exception properly when __file__ is not set, __name__ == '__main__',
and sys.argv[0] is a false value.

Closes issue2743.
2008-05-03 03:19:39 +00:00
Amaury Forgeot d'Arc 607bff1ebe Some tests did not pass on repeated calls (regrtest -R::)
Perform additional cleanup, mostly deleting from sys.modules, or clearing the warnings registry.
2008-04-18 23:31:33 +00:00
Brett Cannon c477427eba Fix spliting on colons on Windows machines with a file path by limiting the
number of splits.
2008-04-13 17:41:31 +00:00
Brett Cannon 25bb8182c6 Add an explicit check for output in a test to try to diagnose a failure on
Windows.
2008-04-13 17:09:43 +00:00
Brett Cannon 667bb4f236 Fix test_warnings by making the state of things more consistent for each test
when it is run.
2008-04-13 02:42:36 +00:00
Brett Cannon e974689038 Re-implement the 'warnings' module in C. This allows for usage of the
'warnings' code in places where it was previously not possible (e.g., the
parser). It could also potentially lead to a speed-up in interpreter start-up
if the C version of the code (_warnings) is imported over the use of the
Python version in key places.

Closes issue #1631171.
2008-04-12 23:44:07 +00:00
Brett Cannon 905c31c73d Add tests for the warnings module; specifically formatwarning and showwarning.
Still need tests for warn_explicit and simplefilter.
2007-12-20 10:09:52 +00:00
Brett Cannon 855da6cbbf Make test_warnings re-entrant. 2007-08-17 20:16:15 +00:00
Brett Cannon 2ee4128e9b Remove test.test_support.guard_warnings_filter.
test.test_support.catch_warning is more full-featured and provides the same
functionality.

Since guard_warnings_filter was added in 2.6 there is no
backwards-compatibility issues.
2007-08-14 05:51:06 +00:00
Walter Dörwald e6dae6c655 Implement a contextmanager test.test_support.catch_warning that can
be used to catch the last warning issued by the warning framework.

Change test_warnings.py and test_structmembers.py to use this
new contextmanager.
2007-04-03 18:33:29 +00:00
Walter Dörwald e1a9b42c38 Add tests for the filename.
Test that the stacklevel is handled correctly.
2007-04-03 16:53:43 +00:00
Walter Dörwald 8bd65000d7 Document that CatchWarningTests is reused by test_structmembers.py. 2007-04-03 16:16:24 +00:00
Walter Dörwald d815d357b2 Move the functionality for catching warnings in test_warnings.py into a separate
class to that reusing the functionality in test_structmembers.py doesn't rerun
the tests from test_warnings.py.
2007-04-03 16:08:10 +00:00
Tim Peters 3249d00f4d Whitespace normalization. 2006-06-27 11:52:49 +00:00
Brett Cannon 53ab5b761d 'warning's was improperly requiring that a command-line Warning category be
both a subclass of Warning and a subclass of types.ClassType.  The latter is no
longer true thanks to new-style exceptions.

Closes bug #1510580.  Thanks to AMK for the test.
2006-06-22 16:49:14 +00:00
Thomas Wouters 767833dc22 Make test_warnings play nice with regrtest -R:: now that regrtest doesn't
always reload the module (specifically, it doesn't reload if the module has
a 'test_main'.)
2006-04-16 15:43:39 +00:00
Neal Norwitz ce4a9c9019 Fix tests so they pass in -R mode 2006-04-09 08:36:46 +00:00
Brett Cannon be66e943c2 Don't filter out OverflowWarning; should be a test failure if it is raised by
the interpreter in 2.5 .
2006-02-27 20:03:56 +00:00
Tim Peters c885443479 Stop producing or using OverflowWarning. PEP 237 thought this would
happen in 2.3, but nobody noticed it still was getting generated (the
warning was disabled by default).  OverflowWarning and
PyExc_OverflowWarning should be removed for 2.5, and left notes all over
saying so.
2004-08-25 02:14:08 +00:00
Raymond Hettinger d6f6e50c9b Reworked test_warnings.py:
* It ran fine under "python regrtest.py test_warnings" but failed under
  "python regrtest.py" presumably because other tests would add to
  filtered warnings and not reset them at the end of the test.

* Converted to a unittest format for better control.  Renamed
  monkey() and unmonkey() to setUp() and tearDown().

* Increased coverage by testing all warnings in __builtin__.

* Increased coverage by testing regex matching of specific messages.
2003-07-13 08:37:40 +00:00
Raymond Hettinger dc9dcf135e This test failed on WindowsME because the full file path did not get
reported consistently with the *nix world.  'Lib/test/test_warnings.py'
came out as 'lib\test\test_warnings.py'.  The basename is all we care
about so I used that.
2003-07-13 06:15:11 +00:00
Jeremy Hylton b6d2f3e07d Don't include slash in search string; it's OS-specific. 2003-07-11 20:22:55 +00:00
Jeremy Hylton 8501466c7f Change warnings to avoid importing re module during startup.
Add API function simplefilter() that does not create or install
regular expressions to match message or module.  Extend the filters
data structure to store None as an alternative to re.compile("").

Move the _test() function to test_warnings and add some code to try
and avoid disturbing the global state of the warnings module.
2003-07-11 15:37:59 +00:00