Ticket #2749 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

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

Reported by: therve Owned by: therve
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.

Change History

Changed 3 years ago by therve

(In [20818]) Basic implementation.

Refs #2749.

Changed 3 years ago by therve

  • keywords review added
  • owner changed from therve to jml
  • cc therve added; jml removed
  • priority changed from normal to highest

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

Changed 3 years ago by therve

Just to show the interest of the feature:

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

Changed 3 years ago by jml

  • owner changed from jml to therve
  • keywords review removed

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.

Changed 3 years ago by therve

(In [21056])

  • docstring cleanup

Refs #2749

Changed 3 years ago by therve

  • owner changed from therve to jml
  • keywords review added

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

Changed 3 years ago by jml

  • keywords review removed
  • owner changed from jml to therve

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

Changed 3 years ago by jml

i.e. please merge this now.

Changed 3 years ago 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.