diff --git a/README.md b/README.md index bfdaaad..380a7cd 100644 --- a/README.md +++ b/README.md @@ -86,10 +86,10 @@ pip install -e . - Works seamlessly with `pytest.approx()`, `mock.ANY` and any custom comparator utilities - Handles complex nested structures intelligently -### **Zero Configuration** -- **Just install and it works** - no setup required -- Can be disabled with `--no-deepassert` flag -- **Drop-in replacement** for standard assertions +### **Simple Opt-In** +- **Enable with `--deepassert` flag** - disabled by default to avoid interference +- No additional configuration needed +- **Drop-in replacement** for standard assertions when enabled --- @@ -225,7 +225,7 @@ E } -#### ✨ **With pytest-deepassert** (with `pytest -vv`) +#### ✨ **With pytest-deepassert** (with `pytest --deepassert -vv`) ``` example_test1.py::test_user_profile_comparison FAILED @@ -355,30 +355,25 @@ E [... standard pytest diff continues below ...] ## 💡 Usage -### **Automatic Enhancement** - -Once installed, `pytest-deepassert` **automatically** enhances all your `==` assertions inside the tests. No code changes required! - - -### **Configuration Options** - -#### Disable deepassert +After installation, enable `pytest-deepassert` by passing the `--deepassert` flag when running pytest: ```bash -pytest --no-deepassert +pytest --deepassert ``` +This will enhance all your `==` assertions inside the tests. No code changes required! + --- ## Configuration -`pytest-deepassert` works out of the box with **zero configuration**. However, you can customize its behavior: +`pytest-deepassert` is **disabled by default** to avoid any interference with your existing test suite. Enable it when needed: ### Command Line Options | Option | Description | |--------|-------------| -| `--no-deepassert` | Disable pytest-deepassert for this test run | +| `--deepassert` | Enable pytest-deepassert for this test run | --- diff --git a/pyproject.toml b/pyproject.toml index 818362a..dfca919 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "pytest-deepassert" -version = "0.2.0" +version = "0.3.0" description = "A pytest plugin for enhanced assertion reporting with detailed diffs" readme = "README.md" requires-python = ">=3.8" diff --git a/src/pytest_deepassert/plugin/hook.py b/src/pytest_deepassert/plugin/hook.py index b87e26f..cdecccb 100644 --- a/src/pytest_deepassert/plugin/hook.py +++ b/src/pytest_deepassert/plugin/hook.py @@ -8,9 +8,9 @@ def pytest_addoption(parser): # type: ignore """Add command line options for pytest-deepassert.""" group = parser.getgroup("deepassert") group.addoption( - "--no-deepassert", + "--deepassert", action="store_true", - help="Disable deep assertion diffs from pytest-deepassert", + help="Enable deep assertion diffs from pytest-deepassert", ) @@ -31,7 +31,7 @@ def pytest_assertrepr_compare( A list of strings representing the formatted comparison output, or None if not handled. """ - if config.getoption("--no-deepassert"): + if not config.getoption("--deepassert"): return None if op != "==":