Ticket #2749 (closed enhancement: fixed )

Opened 2 years ago

Last modified 2 years ago

Add a utility method to trial to check the type of an object

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

Description

We need something like assertIsInstance/failIfIsInstance: assert_(isinstance()) is a pain to debug because it doesn't provide any useful output.

Attachments

Change History

  2007-07-24 10:52:50+00:00 changed by therve

(In [20818]) Basic implementation.

Refs #2749.

  2007-07-24 10:54:26+00:00 changed by therve

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

Ready to review in assertisinstance-2749. It's very straightforward and simple.

  2007-08-10 15:38:14+00:00 changed by therve

Just to show the interest of the feature:

$ grep 'self.\(fail\|assert\).*isinstance' twisted/ -rsi | grep -v '.svn' | wc -l
119

  2007-08-12 01:47:10+00:00 changed by jml

  • keywords deleted
  • owner changed from jml to therve

Looks great! Sorry for the delay in reviewing -- I'm a bum.

Unless things have changed without an appropriately titled notice to the mailing list, we don't indent the second line of a docstring as you've done in the new assert methods. Please dedent the second line of the docstring in failUnlessIsInstance and failIfIsInstance before landing.

You're right, this feature is woefully overdue. Thanks for doing it.

  2007-08-13 12:35:11+00:00 changed by therve

(In [21056])

  • docstring cleanup

Refs #2749

  2007-08-13 12:36:00+00:00 changed by therve

  • keywords set to review
  • owner changed from therve to jml

I don't know why I did that :). Up for review again.

  2007-08-14 00:09:22+00:00 changed by jml

  • keywords deleted
  • owner changed from jml to therve

No need for another review, it's just a whitespace change.

  2007-08-14 00:09:38+00:00 changed by jml

i.e. please merge this now.

  2007-08-14 07:30:37+00:00 changed by therve

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

(In [21068]) Merge assertisinstance-2749

Author: therve Reviewer: jml Fixes #2749

Add a method assertIsInstance on unittest.TestCase? for checking the type of an object.

Note: See TracTickets for help on using tickets.