Blog

python tutorials and learn python

Created with Sketch.

Python patch()

Python patch() Summary: in this tutorial, you’ll learn how to use the Python patch() to replace a target with a mock object temporarily. Introduction to the Python patch The unittest.mock module has a patch() that allows you to temporarily replace a target with a mock object. A target can be a function, a method, or…
Read more

Python Unittest Mock

Python Unittest Mock Summary: in this tutorial, you’ll learn about the Python unittest Mock class and how to use it to mock other classes. Introduction to Python unittest Mock class Mocks simulate the behaviors of real objects. To test an object that depends on other objects in an isolated manner, you use mock objects to…
Read more

Python assertIn()

Python assertIn() Summary: in this tutorial, you’ll learn how to use the Python assertIn() method to test if a member is in a container. Introduction to the Python assertIn() method The assertIn() is a method of the TestCase class of the unittest module. The assertIn() method tests if a member is in a container: assertIn(member,…
Read more

Python assertTrue()

Python assertTrue() Summary: in this tutorial, you’ll learn how to use Python assertTrue() to test if an expression is True and assertFalse() method to test if an expression is False. Introduction to the Python assertTrue() method The assertTrue() is a method of the TestCase class in the unittest module. The assertTrue() method tests if an…
Read more

Python assertIsNone()

Python assertIsNone()   Summary: in this tutorial, you’ll learn how to use the Python assertIsNone() method to test if an expression is None. Introduction to the Python assertIsNone() method The assertIsNone() is a method of the TestCase class of the unittest module. The assertIsNone() test if an expression is None: assertIsNone(expr, msg=None) Code language: Python…
Read more

Python assertIsInstance()

Python assertIsInstance() Summary: in this tutorial, you’ll learn how to use Python assertIsInstance() method to test if an object is an instance of a class. Introduction to the Python assertIsInstance() method The assertIsInstance() is a method of the TestCase class of the unittest module. The assertIsInstance() method tests if an object is an instance of…
Read more

Python assertIs()

Python assertIs() Summary: in this tutorial, you’ll learn how to use the Python assertIs() to test if two objects are the same. Introduction to Python assertIs() method The assertIs() allows you to test if two objects are the same. The following shows the syntax of the assertIs() method: assertIs(first, second, msg=None) Code language: Python (python)…
Read more

Python assertAlmostEqual()

Python assertAlmostEqual() Summary: in this tutorial, you learn how to use the Python assertAlmostEqual() method to test if two values are approximately equal. Introduction to the Python assertAlmostEqual() method The assertAlmostEqual() is a method of the TestCase class of the unittest module. The assertAlmostEqual() test if two values are approximately equal by doing the following:…
Read more

Python assertEqual

Python assertEqual Summary: in this tutorial, you’ll learn how to use the Python assertEqual() method to test if two values are equal. Introduction to the Python assertEqual() method The assertEqual() is a method of the TestCase class of the unittest module. The assertEqual() tests if two values are equal: assertEqual(first, second, msg=None) Code language: Python…
Read more

Python Unittest Assert Methods

Python Unittest Assert Methods Summary: in this tutorial, you’ll learn the overview of the Python unittest assert methods to perform unit testing. Introduction to Python unittest assert methods The TestCase class of the unittest module provides you with a large number of assert methods to test. The following table shows the most commonly used assert…
Read more