[pytest-dev] Converting unittest to pytest (was: Re: ANN: nose2pytest 1.0)

Florian Bruhin me at the-compiler.org
Thu Mar 31 04:36:31 EDT 2016


Hey Thomas,

* Thomas De Schampheleire <patrickdepinguin at gmail.com> [2016-03-31 10:23:00 +0200]:
> On Thu, Mar 31, 2016 at 6:04 AM, oliver <oliver.schoenborn at gmail.com> wrote:
> > Announcing a project hosted on GitHub called nose2pytest
> > (https://github.com/schollii/nose2pytest). This project helps migrate a test
> > suite that was written for Nose to work with pure pytest. It converts
> > nose.tools.assert_ functions into raw assert statements so you can better
> > (IMO) leverage pytest assertion introspection. It may even decrease test
> > suite dependencies by 1; after nose2test has been run on a test suite, it is
> > no longer needed.
> >
> > The nose2pytest script has already successfully converted approximately 5000
> > assertions, so this is v1.0. However, there are many ways to harness Nose
> > functionality so I'm really curious to see if nose2test can be useful to
> > others.
> >
> > I'm sure there is lots of room for improvement. Any feedback or
> > contributions would be much appreciated.
> >
> 
> [...]
>
> I had a very brief look at your nose2pytest code, and at first sight
> it doesn't look complicated to support a unittest2pytest conversion
> too? What do you think of that?

There are already two of those:

https://github.com/pytest-dev/unittest2pytest
https://github.com/dropbox/unittest2pytest

> Aside from the assert functions, another type of conversion I had to
> make was from unittest-style setUp/tearDown functions to pytest-style:
> 
> setUp(self) --> setup_method(self, method)
> tearDown(self) --> teardown_method(self, method)
> setUpClass(cls) --> setup_class(cls)
> __init__(self, ...) --> setup_class(cls)
> ...
> 
> While your README mentions that some replacement can be done with
> simple search/replace, I think it would be most useful if even such
> things were handled by nose2pytest, so that it becomes a one-stop
> solution.

I don't think unittest2pytest (either one) handles that, but I'm not
sure. Let's just not create a third one please :D

Florian

-- 
    http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
       GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
     I'm running a crowdfunding to work on my FOSS-project full-time:
                  http://igg.me/at/qutebrowser
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20160331/03979a99/attachment.sig>


More information about the pytest-dev mailing list