@readmodelmag
MODEL

Tools

Your agent's tests passed. Ask what must always be true

SummaryExample tests only check the cases someone thought of. In our test, three passing example tests missed a bug that dropped data, and one Hypothesis property test found it in a fraction of a second with the smallest failing input.

· MODEL Editors · 2 min read

Some links may be affiliate links. Disclosure

MODEL card on a cream background. Red kicker: BUILDER TIP / PROPERTY-BASED TESTS. Large red text: 0.16 s. Black headline: To catch a bug 3 example tests missed. Bottom left: MODEL. Bottom right: Sources: MODEL test, Nov 29 2026.
Our own test results, November 29, 2026. Illustration by MODEL. Original. Image source.

When a coding agent writes a function, it usually writes the tests too. Those tests tend to check the examples it had in mind, so they pass. The bugs live in the inputs nobody picked.

Property-based testing flips that. Instead of listing examples, you write one rule that must hold for every input, and a library generates the inputs. In Python, the standard tool is Hypothesis: free, open source (MPL-2.0), installed with pip install hypothesis, and it runs inside pytest.

What we did. On Sunday evening we wrote a small helper the way an agent might: split a list into batches of size n. We planted a common off-by-one bug: when the list doesn't divide evenly, the last partial batch is silently dropped.

Three example tests (an even split, a split into threes, an empty list) all passed.

Then we added one property: if you flatten the batches back together, you get the original list.

@given(st.lists(st.integers()), st.integers(min_value=1, max_value=10))
def test_no_items_lost(items, n):
    assert [x for b in chunks(items, n) for x in b] == items

What happened. The test run failed in 0.16 seconds and reported the smallest failing case it could find: items=[0], n=2. One item, batch size two, item gone. Hypothesis tries to reduce a failure to the simplest input before reporting it, which is why the report is that short.

We ran it again and got the same case immediately. Hypothesis saves failures to a local .hypothesis/examples folder and replays them on the next run. After we fixed the loop, all four tests passed.

We also tried the example from Hypothesis's own README: a "sort" that quietly removes duplicates. A normal example test passed. The property "matches Python's sorted()" failed with ls=[0, 0].

How to use it with an agent. Ask it for properties, not just examples. Good ones are usually simple:

  • Nothing lost: output contains every input item.
  • Round trip: encode then decode gives back the original.
  • Same answer as a slow, obviously correct version.
  • Never crashes on any valid input.

The catch. By default Hypothesis tries 100 inputs per test, so a pass is evidence, not proof. A property is only as good as the rule you write, and an agent can write a weak one too, so read it. The saved-failures folder is a cache: the docs say it may be invalidated on upgrades and recommend copying important failures into an @example decorator so they are checked every time.

The MODEL verdict. If an agent wrote both the code and the tests, add one property test before you merge. It takes a few lines and checks the inputs nobody thought to try.

Tested by MODEL Editors on Nov. 29, 2026 with Hypothesis 6.170.24, pytest 9.2.0 and Python 3.13 on Linux, on code we wrote ourselves. Not sponsored. No affiliate links. MODEL has no relationship with Hypothesis.

Get three tested tools every Friday

Free, weekly. Unsubscribe anytime.

Sources

  1. Hypothesis on GitHub (README)

    HypothesisWorks (GitHub)

  2. Hypothesis API reference

    Hypothesis documentation

  3. Replaying failed tests

    Hypothesis documentation

  4. hypothesis on PyPI

    PyPI

FREE · EVERY WEEK

The top AI tools this week, tested.

Every week MODEL's editors pick the AI tools worth your time, try them hands-on, and tell you what's good, what's not, and who it's for. Free, in your inbox.

Free. Unsubscribe anytime. Our picks are editorial and can't be bought.