Category: New Python tutorial

python tutorials and learn python

Created with Sketch.

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

Organizing Code & Running unittest

Organizing Code & Running unittest Summary: in this tutorial, you’ll learn how to organize the test code and how to use the various commands to run unit tests. Organizing code If you have a few modules, you can create test modules and place them within the same directory. In practice, you may have many modules…
Read more

Skipping Tests

Skipping Tests Summary: in this tutorial, you’ll learn how to skip tests using the Python unittest module. The unittest module allows you to skip a test method or a test class. To skip a test, you have three available options: Use the @unittest.skip() decorator. Call the skipTest() method of the TestCase class. Raise the SkipTest…
Read more

Python Test Fixtures

Python Test Fixtures Summary: in this tutorial, you’ll learn about Python test fixtures including setUp() and tearDown() methods. Introduction to the Python Test fixtures By definition, a test fixture is a function or method that runs before and after a block of test code executes. In other words, it is a step carried out before…
Read more

Python unittest

Python unittest Summary: in this tutorial, you’ll learn about the unit test concept and how to use the Python unittest module to perform unit testing. What is a unit test A unit test is an automated test that: Verifies a small piece of code called a unit. A unit can be a function or a…
Read more