Search code examples
pythonpytestpython-unittest

How to go about converting a test-suite from unittest to pytest?


I know that one can run the tests written for unittest directly by pytest. But I want to rewrite them to make use of all that pytest has to offer. So, I would like to know

  1. How to go about doing it manually?
  2. If there is an automated tool which can do or at least partially do it.

Solution

  • I am new to pytest (but not new to xunit). It looks to me like you will spend most of your time refactoring setup and teardown into fixtures. See four phase test.

    If you have a class hierarchy to test look here.