Vikram Bhat

Vikram is a software engineer from the Bay Area and has worked at companies like Sony PlayStation and Box. He has been working on Python for the last 5 years mainly in the areas of software automation, tools, infrastructure and software testing. He really enjoys building tools using Python and learning about best practices in coding and software testing.

Speaker home page

Unit testing using monkey patching in pytest

DevOps, Testing, & Automation, Beginner
8/18/2019 | 1:05 PM-1:35 PM | Fisher West

Description

Unit testing is loved by so many that it is already a very popular concept. But I will try to make unit testing even simpler with pytest using monkey patching. Come to learn about unit testing with pytest using monkey patching.

Abstract

Everyone loves unit testing. Developers rarely submit code for reviews without adding unit testing. But can we make this writing unit tests even simpler in Python?

PyTest provides us with an amazing set of tools and libraries to write functional tests, but can PyTest be used for Unit testing also? Of course it can! Not only can you write simple unit tests with PyTest, you can write tests for complex logic as well as code which depend on external services using PyTest. Having worked on PyTest for the last 5 years, I was amazed at the power and capabilities of PyTests for writing quality tests.

Monkey Patching is a common concept, but it is not used widely outside of unit-tests. Python has its own internal libraries for writing unit tests and mocking, MonkeyPatching using PyTest makes the tests a lot simpler to write..

We will cover how PyTest, MonkeyPatching and Unit tests come together to not only make it easy to write tests, but also make it fun.

This talk is for all levels and does not require any specific knowledge of PyTest.