Ticket #2626 (closed enhancement: fixed )

Opened 2 years ago

Last modified 2 years ago

trial needs something to check DeprecationWarning

Reported by: therve Assigned to: therve
Type: enhancement Priority: highest
Milestone: Component: trial
Keywords: Cc: exarkun, jml, therve, ralphm
Branch: Author:
Launchpad Bug:

Description

There is a method in test_process.ProcessTestCase that asserts that a function call produce a warning. It's a bit like util.supress, but with checking the content of the warning, and I think that would be great for the deprecation policy.

Attachments

Change History

  2007-05-05 08:13:17+00:00 changed by jml

I've added something like this in the setUpClass-2303-2 branch (currently stalled due to lack of gtk1 support in feisty).

  2007-05-06 14:40:53+00:00 changed by exarkun

  • cc set to exarkun

Where in that branch is the relevant code? I looked around for a minute but I didn't see any likely candidates. I was going to split it out into a separate branch so we could go ahead with this without waiting for #2303.

  2007-05-06 23:40:21+00:00 changed by jml

t.trial.util.collectWarnings. It isn't quite what's described, but it's the first step.

  2007-05-29 10:35:54+00:00 changed by therve

Note that it's in the ireporter-2164 branch, no setUpClass-2303.

  2007-05-29 12:48:16+00:00 changed by therve

  • owner changed from jml to therve

  2007-05-29 12:54:46+00:00 changed by therve

  • cc changed from exarkun to exarkun, jml, therve
  • keywords set to review
  • owner deleted
  • priority changed from normal to highest

Ready to review in assert-warn-2626.

  2007-06-03 21:38:03+00:00 changed by exarkun

  • keywords deleted
  • owner set to therve

Looks nice. A few things:

  • No coverage for the code which suppresses the __warningregistry__ for the function being tested (covering that probably just involves using assertWarn twice with the same function)
  • I think args and kwargs should be *args and **kwargs. If this is a practical problem for someone, we can fix it later (by defining all the positional arguments with *args).
  • assertWarns closes matches the naming style of assertRaises
  • The function being tested might result in multiple warnings; there's no way to test such a function the way assertWarn works now. It'd be fine to defer that functionality to another ticket/time though.

  2007-06-04 09:19:30+00:00 changed by therve

  • keywords set to review
  • owner deleted

I've addressed the 3 points. The last functionality could be useful, but I don't think that's a high priority.

  2007-06-07 13:52:46+00:00 changed by ralphm

  • cc changed from exarkun, jml, therve to exarkun, jml, therve, ralphm
  • keywords deleted
  • owner set to therve

Reviewed the last change set. Looking good. Please merge.

Maybe create a ticket for the latter point raised by exarkun?

  2007-06-07 14:24:19+00:00 changed by therve

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

(In [20485]) Merge assert-warn-2626

Author: therve Reviewer: ralphm, exarkun Fixes #2626

Add an assertWarns method on unittest.TestCase? that allows to check a warning is emitted when a function is called.

Note: See TracTickets for help on using tickets.