Skip to main content

Replacing Nose with Pytest as the test runner

· 2 min read

For Python SDKs, the test runner used to run unit tests was Nose. As its maintenance support is coming to an end, APIMatic has replaced nose with Pytest for all future test suites.


Python SDK with Pytest as the test runner will be made live on 2022-10-01.


Previously the test runner used by APIMatic’s Python SDK was nose. The command used to run the test suite (written using unittest) was nosetests. However, nose is no longer maintained and doesn’t give the expected behavior with newer versions of Python 3. This has created an issue for the users wanting to run tests with Python 3+.

What Has Changed?

The test runner is now changed to Pytest. Pytest is capable of running the same test written in unittest. Users will now require Pytest to run the unit tests that come along with the Python SDK.

Change in the CI command

You simply need to use pytest as the command to run all the unit tests. Pytest will run all files of the form or ** in the current directory and its subdirectories. More generally, it follows standard test discovery rules. Please note that the test-requirements.txt file in the SDK has also been changed so that Pytest can be automatically installed instead of nose when the installation is run.

Change in the test cases

There is a slight change in the structure of the test cases. The self.assert* statements have been replaced with plain assert statements. Please note that this causes no functional changes and the output of the test cases should remain the same.

Change in the README file

The README files have been updated to reflect the new command to run the tests.