From ed9e1af6b163cb78d29dfaeb7f03f14a9caef829 Mon Sep 17 00:00:00 2001 From: Alexander Kuzmik Date: Tue, 4 Nov 2025 12:59:46 +0100 Subject: [PATCH 1/3] Bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 79a1866..818362a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "pytest-deepassert" -version = "0.1.3" +version = "0.2.0" description = "A pytest plugin for enhanced assertion reporting with detailed diffs" readme = "README.md" requires-python = ">=3.8" From 55ac81455a7c32b29d598a47a94d96a9eca6e25f Mon Sep 17 00:00:00 2001 From: Alexander Kuzmik Date: Tue, 4 Nov 2025 13:03:20 +0100 Subject: [PATCH 2/3] Update readme --- README.md | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a5a52d8..e816132 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ ## Table of Contents -- [Why pytest-deepassert?](#why-pytest-deepassert) +- [What is it for?](#what-is-it-for) - [How it works](#how-it-works) - [Installation](#installation) - [Key Features](#key-features) @@ -384,18 +384,43 @@ pytest --no-deepassert --- -## Limitations +## API Reference -The tool only enhances assertions inside the test modules (pytest limitation). -If you want to have deep assertion reports in the other modules of your project (e.g. some helper functions for your testlib), consider using `pytest_deepassert.equal(left, right)` function. +### `pytest_deepassert.equal(left, right, verbose_level=2)` + +For use cases where you need enhanced assertions outside of test modules (e.g., in helper functions), you can use the `equal()` function directly. + +**Parameters:** +- `left` (Any): The expected object +- `right` (Any): The actual object +- `verbose_level` (int, optional): Controls the verbosity of the diff report. Default: `2` + - `0`: Minimal output (only reports if objects are different) + - `1`: Standard output (shows changes with brief details) + - `2`: Detailed output (shows full changes with all details and types) + +**Example:** ```python import pytest_deepassert def helper_function_for_assertion(actual, expected): - pytest_deepassert.equal(actual, expected) # Enhanced diff on failure + # Use default verbose_level=2 for detailed output + pytest_deepassert.equal(expected, actual) + +def another_helper(actual, expected): + # Use verbose_level=1 for less detailed output + pytest_deepassert.equal(expected, actual, verbose_level=1) ``` +**Note:** The traceback will automatically hide the internal frames of the `equal()` function, showing only where it was called from. + +--- + +## Limitations + +The tool only enhances assertions inside the test modules (pytest limitation). +If you want to have deep assertion reports in the other modules of your project (e.g. some helper functions for your testlib), consider using `pytest_deepassert.equal(left, right)` function as described in the [API Reference](#api-reference) section. + --- From 0f92982f3ddfc0e13016f289eeb225aabbf8a33b Mon Sep 17 00:00:00 2001 From: Alexander Kuzmik Date: Tue, 4 Nov 2025 13:04:57 +0100 Subject: [PATCH 3/3] Fix linter --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e816132..bfdaaad 100644 --- a/README.md +++ b/README.md @@ -392,7 +392,7 @@ For use cases where you need enhanced assertions outside of test modules (e.g., **Parameters:** - `left` (Any): The expected object -- `right` (Any): The actual object +- `right` (Any): The actual object - `verbose_level` (int, optional): Controls the verbosity of the diff report. Default: `2` - `0`: Minimal output (only reports if objects are different) - `1`: Standard output (shows changes with brief details) @@ -406,7 +406,7 @@ import pytest_deepassert def helper_function_for_assertion(actual, expected): # Use default verbose_level=2 for detailed output pytest_deepassert.equal(expected, actual) - + def another_helper(actual, expected): # Use verbose_level=1 for less detailed output pytest_deepassert.equal(expected, actual, verbose_level=1)