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

Cesar Canassa cesar.canassa at gmail.com
Mon Jan 19 16:33:10 CET 2015


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.


Best,
Cesar Canassa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20150119/8ddc4b25/attachment.html>


More information about the pytest-dev mailing list