Ticket #2703 (closed enhancement: fixed )

Opened 2 years ago

Last modified 2 years ago

assertWarns has some restrictions

Reported by: therve Assigned to: therve
Type: enhancement Priority: highest
Milestone: Component: core
Keywords: Cc: exarkun
Branch: Author:
Launchpad Bug:

Description (last modified by therve)

First uses of assertWarns have shown some limits:

  • it can't be used to check warnings emitted by class instantiation or implicit __call__ method
  • it doesn't work with warnings filtered by default like PendingDeprecationWarning

Attachments

Change History

  2007-06-11 09:54:14+00:00 changed by therve

  • keywords set to review
  • owner deleted
  • priority changed from normal to highest

Ready to review in assertwarns-features-2703.

  2007-06-11 23:29:36+00:00 changed by jml

What exactly do you mean by "it can't be used with class"?

  2007-06-12 08:05:26+00:00 changed by therve

  • description deleted

I've modified the description to reflect what I meant.

  2007-06-18 12:49:46+00:00 changed by exarkun

Arg, I hate the stupid warnings module.

Noble effort, but the only actually correct way to get __warningsregistry__ is to go through the same dance as warnings.warn. Even if we duplicate it, there's no guarantee Python devs won't change it randomly for the next release.

I'm trying to remember why we don't do something like patch warnings.warn_explicit instead of trying to re-assemble the events after the fact. I think the reason we didn't patch warnings.warn was to support from warnings import warn, but I can't think of a similar reason not to patch warn_explicit.

(This is not a review, just some thoughts.)

  2007-06-18 13:51:18+00:00 changed by therve

We dont't patch warn_explicit because we didn't implemented like that at the beginning :). I guess that could work though.

  2007-06-18 14:18:56+00:00 changed by therve

I've tried it, and it's too good to be true :).

  2007-06-23 20:20:17+00:00 changed by exarkun

  • keywords deleted
  • owner set to therve

Hmm, for me, some tests in twisted.trial.test.test_tests fail w/ this branch merged into trunk, mostly similar to this:

===============================================================================
[FAIL]: twisted.trial.test.test_tests.SuppressionTest.testSuppressModule
Traceback (most recent call last):
  File "/home/exarkun/Projects/Twisted/trunk/twisted/trial/test/test_tests.py", line 507, in testSuppressModule
    self.assertSubstring(suppression.METHOD_WARNING_MSG, self.getIO())
  File "/home/exarkun/Projects/Twisted/trunk/twisted/trial/unittest.py", line 307, in failUnlessSubstring
    return self.failUnlessIn(substring, astring, msg)
twisted.trial.unittest.FailTest: 'method warning message' not in ''
-------------------------------------------------------------------------------

  2007-06-23 21:05:08+00:00 changed by therve

  • cc set to exarkun
  • keywords set to review
  • owner deleted

Damn, sorry, that was something stupid.

  2007-06-23 22:22:22+00:00 changed by exarkun

  • keywords deleted
  • owner set to therve

No problem. Looks great, please merge :)

  2007-06-24 08:35:59+00:00 changed by therve

  • status changed from new to closed
  • resolution set to fixed

(In [20610]) Merge assertwarns-features-2703

Author: therve Reviewer: exarkun Fixes #2703

Fix implementation of assertWarns to work with all callables and with all type of warnings.

Note: See TracTickets for help on using tickets.