0% found this document useful (0 votes)
9 views8 pages

Python Unit Testing Guide for Beginners

The document outlines a Python Programming course for the 2025-2026 academic year, led by Dr. Hanafi M. Yassine, covering topics from basic to advanced Python and XML bindings. It also discusses unit testing, specifically using Python's unittest framework, which allows for systematic testing of code functionality. Key outcomes of unit testing include OK, FAIL, and ERROR statuses based on test results.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views8 pages

Python Unit Testing Guide for Beginners

The document outlines a Python Programming course for the 2025-2026 academic year, led by Dr. Hanafi M. Yassine, covering topics from basic to advanced Python and XML bindings. It also discusses unit testing, specifically using Python's unittest framework, which allows for systematic testing of code functionality. Key outcomes of unit testing include OK, FAIL, and ERROR statuses based on test results.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Engineering: Computer Security.

Semester: 05.

Python Programming

Year: 2025-2026 By Dr. HANAFI [Link]


Course Content

▪ Introduction about the course.

▪ Part 1: Beginning Python

▪ Part 2: Advanced Python

▪ Part 3: Python Workbook

▪ Part 4: Generating Python Bindings for XML


UNIT TESTS
Unit Tests
Unit Testing is the first level of software testing where the smallest testable parts of
software are tested. This is used to validate that each software unit performs as designed.

Python Unittest is a built-in testing framework that provides a set of tools for testing our
code’s functionality in a more systematic and organized manner.

With unittest framework, we can create test cases, fixtures, and suites to verify if our
code behaves as expected.

It allows us to write test methods within classes that check different aspects of our code
such as input, output, and edge cases.

It also supports test discovery making it easy for us to automate test execution across our
project.

Unit Tests
Assert Methods
unittest has lots of methods to assert on the values, types, and existence of variables.
Below are some of the methods that are commonly used to write assertions.

Unit Tests
Python Unittest Example

Unit Tests
Outcomes Possible in Unit Testing
✓ OK–This means that all the tests are passed.

✓ FAIL– This means that the test did not pass and an Assertion Error exception is raised.

✓ ERROR–This means that the test raises an exception other than AssertionError.

Unit Tests
Q&A

You might also like