Supercharge Testing by Mocking

Aaditya M Nair (~AadityaNair)


2

Votes

Description:

Testing is one of the cornerstones of good software engineering. It addition to help ensure that your code works as expected, it also has the advantage of iterating over your code faster. With sufficient tests, you can be pretty sure that your new code doesn't break any old ones. One of the biggest issue I find with writing tests is that there is a lot of boilerplate code that needs to be written to get even the basic unittests to work.

This talk will focus on mock and patch. These are awesome utilities provided with unittest module to make your testing life much more painless but not a lot of people know about them. The flow of the talk will be as follows: <br/>

  1. Intro to testing: Why do we actually need testing?
  2. The basic problem I find with testing: Boilerplate code. (with examples)
  3. Introduction to MagicMock and patch.
  4. Applying them to real tests.
  5. Enhancing those tests: Assertions on mock.
  6. Caveats associated with their use.

Prerequisites:

Some basic knowledge about unit testing in Python would be great.

Content URLs:

Talk: https://slides.com/aadityamnair/pycon/

References:<br> https://docs.python.org/3/library/unittest.mock.html<br> https://docs.python.org/3/library/unittest.mock-examples.html

Speaker Info:

I am a student at IIIT-Hyderabad on the verge of completing my M.S. For the last two years, I have also been working part-time as a sysadmin for all institute servers and was involved in maintaining services like proxy, directory and the mail server.

I have previously interned as a Production Engineer for Facebook and am currently a Google Summer of Code intern with CCExtractor.

Speaker Links:

Github

LinkedIn

Blog

Section: Developer tools and Automation
Type: Talks
Target Audience: Beginner
Last Updated: