Opened 10 years ago

Last modified 9 years ago

#4991 enhancement new

Deprecate the redundant assertion method aliases on `twisted.trial.unittest.TestCase`

Reported by: Jean-Paul Calderone Owned by:
Priority: normal Milestone:
Component: trial Keywords:
Cc: Jonathan Lange, Julian Berman Branch:
Author:

Description

Per the mailing list discussion, TestCase methods names, after #4989 and #4990 are resolved, we should deprecate assertEquals, failUnlessEquals, and so on, leaving just the assertEqual style of methods.

Attachments (1)

deprecate-fail-methods.patch (19.7 KB) - added by Julian Berman 9 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 10 years ago by DefaultCC Plugin

Cc: Jonathan Lange added

comment:2 Changed 10 years ago by jknight

Also remove failIf*, failUnless*, and assert_, right?

comment:3 Changed 10 years ago by Jean-Paul Calderone

Deprecate for now, yes. We should end up with a single preferred spelling for each kind of assertion.

comment:4 Changed 9 years ago by Julian Berman

Cc: Julian Berman added
Keywords: review added

Attached a patch that does the deprecations. I had a bit of trouble with twisted.python.deprecate -- the tests I wrote fail because deprecate produces for my modifications things like "twisted.trial.unittest.failIf was deprecated in Twisted 13.0.0" whereas callDeprecated is expecting a fully qualified path to the TestCase being run. Hoping someone can give me a pointer there on what needs modifying.

I'll open another ticket for fixing the test suite to not use the deprecated aliases, unless someone speaks up and prefers it be done here.

Changed 9 years ago by Julian Berman

comment:5 Changed 9 years ago by Jean-Paul Calderone

I'll open another ticket for fixing the test suite to not use the deprecated aliases, unless someone speaks up and prefers it be done here.

That ticket already exists, #4990, and needs to be resolved before this one.

comment:6 Changed 9 years ago by Jean-Paul Calderone

Uhh. It seems it is "resolved" already, even though the issue it describes is not actually fixed. I guess that means we do need another ticket.

comment:7 Changed 9 years ago by Julian Berman

Keywords: review removed

comment:8 Changed 9 years ago by Tom Prince

A couple of review points, for whoever rebases this patch.

  1. It would be better to keep the alternate names beside the canonical name.
  1. The tests that explicitly call deprecate methods should explicitly handle the warning, so that running with warnings enabled doesn't spuriously report them.

comment:9 Changed 9 years ago by Julian Berman

For reference, the list of methods that this ticket will aim to deprecate attempt to leave one preferred spelling for each assertion. The preferred spelling is the one preferred by pyunit where possible. Therefore, the deprecations are as follows:

fail*(, which are all provided as assert*( methods *Equals(, which are provided by *Equal( assert_ -> assertTrue assertNot -> assertFalse assertIdentical -> assertIs assertNotIdentical -> assertIsNot assertSubstring -> assertIn assertNotSubstring -> assertNotIn

comment:10 Changed 9 years ago by Julian Berman

Argh, sorry, maybe in a few years I will learn how to WikiFormat. Dup-posting for readability.

For reference, the list of methods that this ticket will aim to deprecate attempt to leave one preferred spelling for each assertion. The preferred spelling is the one preferred by pyunit where possible. Therefore, the deprecations are as follows:

  • fail*(, which are all provided as assert*( methods
  • *Equals(, which are provided by *Equal(
  • assert_ -> assertTrue
  • assertNot -> assertFalse
  • assertIdentical -> assertIs
  • assertNotIdentical -> assertIsNot
  • assertSubstring -> assertIn
  • assertNotSubstring -> assertNotIn

comment:11 Changed 9 years ago by Tom Prince

:)

  • fail*(, which are all provided as assert*( methods
  • *Equals(, which are provided by *Equal(
  • assert_ -> assertTrue
  • assertNot -> assertFalse
  • assertIdentical -> assertIs
  • assertNotIdentical -> assertIsNot
  • assertSubstring -> assertIn
  • assertNotSubstring -> assertNotIn

(bullets and numbered list need a leading space)

comment:12 Changed 9 years ago by Tom Prince

Note that twisted doesn't actually have assertIs.

comment:13 Changed 9 years ago by Julian Berman

Tickets #6220 - #6233 need to be done first before this can happen.

Note: See TracTickets for help on using tickets.