<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Assertions on Ghafoor's Personal Blog</title><link>http://ghafoorsblog.com/tags/assertions/</link><description>Recent content in Assertions on Ghafoor's Personal Blog</description><generator>Hugo</generator><language>en</language><managingEditor>noreply@example.com (AG Sayyed)</managingEditor><webMaster>noreply@example.com (AG Sayyed)</webMaster><copyright>Copyright © 2024-2026 AG Sayyed. All Rights Reserved.</copyright><lastBuildDate>Sat, 16 May 2026 17:42:12 +0100</lastBuildDate><atom:link href="http://ghafoorsblog.com/tags/assertions/index.xml" rel="self" type="application/rss+xml"/><item><title>Debug With Assert</title><link>http://ghafoorsblog.com/courses/google/it-automation-content/it-automation-python-pcert/04-troubleshooting-debugging/04-module/003-debug-with-assert/</link><pubDate>Thu, 13 Nov 2025 13:46:44 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/google/it-automation-content/it-automation-python-pcert/04-troubleshooting-debugging/04-module/003-debug-with-assert/</guid><description>&lt;p class="lead text-primary"&gt;
This document explores debugging Python programs using assert statements as sanity checks to catch bugs early in development. Assertions validate assumptions, check preconditions, verify intermediate states, and provide clear error messages when conditions fail, enabling proactive bug detection throughout the coding process.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="introduction"&gt;Introduction&lt;/h2&gt;
&lt;p&gt;A developer&amp;rsquo;s worst nightmare is spending hours developing code only to discover multiple bugs right before deployment. Instead of waiting until the last minute to check code correctness, developers should test and validate throughout the development process. Assert statements provide a mechanism for these continuous sanity checks.&lt;/p&gt;</description></item><item><title>Writing Assertion</title><link>http://ghafoorsblog.com/courses/ibm/devops-content/devops-pcert/11-tdd-bdd/02-module/005-writingg-asseertion/</link><pubDate>Tue, 22 Jul 2025 22:47:46 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/devops-content/devops-pcert/11-tdd-bdd/02-module/005-writingg-asseertion/</guid><description>&lt;p class="lead text-primary"&gt;
This document details the process of writing and refining test assertions, debugging failing tests, and building robust test cases for stack operations using Python's unittest framework.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="introduction"&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Writing effective test assertions is a key part of developing reliable software. This module demonstrates a workflow for debugging and improving test cases, using a stack implementation as an example.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="debugging-failing-tests"&gt;Debugging Failing Tests&lt;/h2&gt;
&lt;p&gt;When running tests, failures indicate that either the code or the test needs attention. Test runners like &lt;code&gt;nose&lt;/code&gt; or &lt;code&gt;unittest&lt;/code&gt; can stop at the first failure using the &lt;code&gt;--stop&lt;/code&gt; flag, helping to focus on one issue at a time.&lt;/p&gt;</description></item><item><title>Test Assertion</title><link>http://ghafoorsblog.com/courses/ibm/devops-content/devops-pcert/11-tdd-bdd/02-module/004-test-assertion/</link><pubDate>Tue, 22 Jul 2025 22:44:16 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/devops-content/devops-pcert/11-tdd-bdd/02-module/004-test-assertion/</guid><description>&lt;p class="lead text-primary"&gt;
This document explores the purpose and use of assertions in Python testing, highlights common PyUnit assertions, and explains the importance of testing both happy and sad paths for robust code validation.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="introduction"&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Assertions are statements in test cases that check if a condition is true or false. They are essential for determining whether code behaves as expected. If an assertion fails, the test fails, helping identify issues early.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="using-assertions-in-python"&gt;Using Assertions in Python&lt;/h2&gt;
&lt;p&gt;Assertions can be made using Python&amp;rsquo;s built-in &lt;code&gt;assert&lt;/code&gt; statement or with specialized assertion methods provided by test frameworks like PyUnit (unittest). These methods make tests more readable and expressive.&lt;/p&gt;</description></item><item><title>Test Case Anatomy</title><link>http://ghafoorsblog.com/courses/ibm/devops-content/devops-pcert/11-tdd-bdd/02-module/003-test-case-anatomy/</link><pubDate>Tue, 22 Jul 2025 22:19:01 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/devops-content/devops-pcert/11-tdd-bdd/02-module/003-test-case-anatomy/</guid><description>&lt;p class="lead text-primary"&gt;
This document explores the anatomy of a test case, including the use of test fixtures, the importance of assertions, and how frameworks help structure reliable and repeatable tests using a stack example.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="introduction"&gt;Introduction&lt;/h2&gt;
&lt;p&gt;A test case is a fundamental unit in software testing, designed to verify that a specific part of code behaves as expected. Test frameworks provide tools to create, organize, and run these test cases efficiently.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="understanding-the-stack-example"&gt;Understanding the Stack Example&lt;/h2&gt;
&lt;p&gt;A stack is a data structure that follows the Last-In, First-Out (LIFO) principle. Items are added to the top using the &lt;code&gt;push&lt;/code&gt; operation and removed from the top using &lt;code&gt;pop&lt;/code&gt;. The &lt;code&gt;peek&lt;/code&gt; operation allows viewing the top item without removing it.&lt;/p&gt;</description></item></channel></rss>