Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.


---

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down