Category python-pytest

Pytest file execution

Pytest File Execution In this chapter, we will learn how to execute single and multiple test files. We have created a test file, test_square.py. Create a new test file, test_compare.py, with the following code: def test_greater(): num = 100 assert…

Introduction to Pytest

Introduction to Pytest Pytest is a Python-based testing framework for writing and executing test code. In today’s REST services, pytest is primarily used for API testing, although we can use pytest to write both simple and complex tests, meaning we…

Pytest Tutorial

Pytest Tutorial Pytest is a Python-based testing framework. It is primarily used for writing API test cases. This tutorial helps you understand… Installing pytest. Various concepts and features of pytest. Sample programs. By the end of this tutorial, you should…

Pytest runs tests in parallel

Pytest Running Tests in Parallel By default, pytest runs tests sequentially. In real-world scenarios, a test suite might have many test files, each with a number of tests. This can lead to significant execution time. To overcome this, pytest provides…

Pytest Summary

Pytest Summary In this pytest tutorial, we covered the following: Installing pytest. Identifying test files and test functions. Use pytest -v to execute all test files. Use pytest <filename> -v to execute a specific file. Execute tests by substring matching:…

Pytest Conclusion

Pytest Conclusion This tutorial introduced you to the pytest framework. Now you should be able to start writing tests using pytest. As a good practice: Create different test files based on the function/module being tested. Give test files and methods…

Pytest environment setup

Pytest Environment Setup In this chapter, we will learn how to install pytest. To start the installation, execute the following command – pip install pytest == 2.9.1 We can install any version of pytest. Here, 2.9.1 is the version we…