[pytest-dev] Automatically converting unittest asserts to py.test asserts.

holger krekel holger at merlinux.eu
Mon Jan 19 16:50:22 CET 2015


Hi Cesar,

On Mon, Jan 19, 2015 at 13:33 -0200, Cesar Canassa wrote:
> Hi,
> 
> In my current company, I recently switched from using Unittest to Py.test
> in our Flask application. I loved Py.test and I decided to start rewriting
> our tests using Py.test style asserts instead of Unittest asserts
> (self.assertEqual, self.assertFalse, et al).
> 
> Since we have already written hundreds of thousands of lines of test code,
> manually converting the tests would take too long, so I have decided to
> automate the process. The automation effort resulted in this script:
> 
> https://gist.github.com/canassa/4fd63d682d90f5e3f07e
> 
> The script is not perfect, you still need to manually review some changes
> it makes, but at least in our project it worked amazingly well, so I
> decided to share it with you.

Thanks.  There also is a tool that (for historic reason) comes with "py",
namely py.convert_unittest, which is always installed with py.test.
Can you imagine to do a proper pytest_convert_unittest repository which
we can then link prominently from pytest.org?  I am sure there are others
who are interested in this.

cheers,
holger

> 
> Best,
> Cesar Canassa

> _______________________________________________
> pytest-dev mailing list
> pytest-dev at python.org
> https://mail.python.org/mailman/listinfo/pytest-dev



More information about the pytest-dev mailing list