August 2018
Beginner
160 pages
4h 8m
English
Once you have changed the test runner to pytest, you can take advantage of writing plain assert statements instead of self.assert* methods.
Converting all the method calls is boring and error-prone, that's why the unittest2pytest tool exists. It converts all self.assert* method calls to plain asserts, and also converts self.assertRaises calls to the appropriate pytest idiom.
Install it using pip:
λ pip install unittest2pytest
Once installed, you can now execute it on the files you want:
λ unittest2pytest test_simple2.pyRefactoringTool: Refactored test_simple2.py--- test_simple2.py (original)+++ test_simple2.py (refactored)@@ -5,6 +5,7 @@ import unittest from collections import namedtuple from pathlib ...
Read now
Unlock full access