Pytest Fixtures and Yield

Hi 👋 In this short article I want to explain the use of the yield keyword in pytest fixtures. What is pytest? Pytest is a complex python framework used for writing tests. It has lots of advanced features and it supports plugins. Many projects prefer pytest in addition to Python’s unitttest library. What is a fixture? A test fixture is a piece of code that fixes some common functionality that is required for writing the unit tests....

December 14, 2021 · 3 min · Denis Nuțiu

How to write parametrized tests in Python with pytest 🎥

Hi 👋 Welcome to another video tutorial on how to write parametrized tests in Python using pytest. If you want to follow along, here’s the code that I’ve tested in the video. from typing import List class Solution: def move_zeroes(self, nums: List[int]) -> None: last_zero = 0 index = 0 while index < len(nums): if nums[index] != 0: nums[last_zero], nums[index] = nums[index], nums[last_zero] last_zero += 1 index += 1 def main(): solution = Solution() arr = [1,0,1] solution....

September 30, 2021 · 1 min · Denis Nuțiu