This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: 2to3 fixer for deprecated unittest method names
Type: enhancement Stage: resolved
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ezio.melotti Nosy List: Arfrever, benjamin.peterson, berker.peksag, bfroehle, ezio.melotti, georg.brandl, gregory.p.smith, loewis, martin.panter, michael.foord, python-dev, r.david.murray, serhiy.storchaka
Priority: normal Keywords: needs review, patch

Created on 2010-12-15 19:36 by ezio.melotti, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue10712.diff ezio.melotti, 2010-12-15 19:36 fixer + tests against 2.7
issue10712_v2.diff berker.peksag, 2013-03-06 20:28 review
issue10712-2.diff ezio.melotti, 2013-11-23 18:50 review
Messages (16)
msg124054 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-12-15 19:36
The attached patch against 2.7 adds a new fixer to 2to3 that replaces deprecated unittest method names with the correct ones.
There are a few issues:
1) only the "safe" renamings are included; the assert[SameElements|ItemsEqual|CountEqual] and the  assert*Regexp*->assert*Regex* changes are missing;
2) unless 2to3 provides a way to specify a target version (e.g. 3.2 rather than just 3.x), the missing renamings can't be included;
3) the patch is against 2.7 but I'm not sure in what versions could/should be included, or if the fixer should (also|only) go on PyPI;
4) this fixer is useful from 3.1 to 3.2 too, is there a way to use it with 3.x versions only?
5) doc is still missing;
msg124076 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-12-15 22:19
2to3 patches should currently be made against and checked into the sandbox.
msg132837 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-04-03 14:07
Should this still go to the sandbox? and if so, what is the right sandbox?
msg168800 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-08-21 20:07
Ping.
msg176759 - (view) Author: Bradley Froehle (bfroehle) * Date: 2012-12-01 21:22
Bikeshedding, but the fixer name of 'asserts' bugs me.  I'd suggest 'unittest' or 'unittest_asserts'.
msg176765 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2012-12-01 22:06
Looks fine, though. Make sure to add docs to library/2to3.rst.
msg183321 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-03-02 13:17
Can this still go on 2.7/3.2/3.3?
msg183330 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2013-03-02 17:12
Yes! 2to3 features are allowed in stable releases.
On Mar 2, 2013 5:17 AM, "Ezio Melotti" <report@bugs.python.org> wrote:

>
> Ezio Melotti added the comment:
>
> Can this still go on 2.7/3.2/3.3?
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue10712>
> _______________________________________
>
msg183613 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2013-03-06 20:28
I've converted Ezio's patch to Mercurial format, updated the lib2to3 documentation and added tests for assertRegexpMatches and assertRaisesRegexp aliases[1].

[1] http://docs.python.org/3.4/library/unittest.html#deprecated-aliases
msg183639 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-03-07 08:10
There are reasons why Ezio did not include assert*Regexp*->assert*Regex* in his patch.
msg204074 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-11-23 18:50
Here is an updated patch that is the same as my first patch but also includes the documentation provided by Berker (thanks!).
msg204075 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-23 19:09
LGTM.
msg204076 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-11-23 19:15
New changeset cc0fc4e9b494 by Ezio Melotti in branch 'default':
#10712: 2to3 has a new "asserts" fixer that replaces deprecated names of unittest methods.
http://hg.python.org/cpython/rev/cc0fc4e9b494
msg204077 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-11-23 19:16
Committed in 3.4, I'll backport it to 2.7/3.3 later.
Thanks for the review!
msg228945 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-10-10 03:16
I committed this to 2.7 in 9336b470544b but screwed up the copy and paste of the issue number so it didn't auto post.
msg230377 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2014-10-31 18:56
Thanks!
History
Date User Action Args
2022-04-11 14:57:10adminsetgithub: 54921
2014-10-31 18:56:14ezio.melottisetmessages: + msg230377
2014-10-10 03:16:13r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg228945

resolution: fixed
stage: commit review -> resolved
2013-11-23 19:16:51ezio.melottisetmessages: + msg204077
stage: patch review -> commit review
2013-11-23 19:15:00python-devsetnosy: + python-dev
messages: + msg204076
2013-11-23 19:09:02serhiy.storchakasetmessages: + msg204075
2013-11-23 18:50:29ezio.melottisetfiles: + issue10712-2.diff

messages: + msg204074
2013-11-16 22:33:13martin.pantersetnosy: + martin.panter
2013-11-16 17:03:03serhiy.storchakasetversions: - Python 3.2
2013-03-07 08:10:57serhiy.storchakasetmessages: + msg183639
2013-03-06 20:28:27berker.peksagsetfiles: + issue10712_v2.diff

nosy: + berker.peksag
messages: + msg183613

components: + 2to3 (2.x to 3.x conversion tool)
2013-03-02 17:12:37gregory.p.smithsetmessages: + msg183330
2013-03-02 13:17:07ezio.melottisetmessages: + msg183321
2012-12-03 08:04:25Arfreversetnosy: + Arfrever
2012-12-01 22:06:48benjamin.petersonsetmessages: + msg176765
2012-12-01 21:22:16bfroehlesetnosy: + bfroehle
messages: + msg176759
2012-12-01 14:31:56serhiy.storchakasetnosy: + serhiy.storchaka
2012-11-23 20:08:21ezio.melottisetnosy: + gregory.p.smith

versions: + Python 3.3, Python 3.4
2012-08-21 20:07:27ezio.melottisetmessages: + msg168800
2011-04-03 14:07:52ezio.melottisetmessages: + msg132837
2011-04-02 23:55:58ezio.melottisetassignee: ezio.melotti
2010-12-15 22:19:42loewissetnosy: + loewis
messages: + msg124076
2010-12-15 19:36:34ezio.melotticreate