Yang Bo
Yang Bo

Reputation: 3728

How to create and compare syrupy snapshots in hypothesis's stateful testing?

I want to create a hypothesis.stateful.RuleBasedStateMachine to run stateful testing in Python. When the test is running, I want it to be deterministic and either update some snapshots or compare with existing, so that I can manually review whether the changes in the snapshot makes sense.

Normally I can use syrupy's snapshot assertion fixture to compare and update snapshot files.

Unfortunately, hypothesis's stateful testing does not support fixtures, therefore I cannot directly use the snapshot fixture.

What should I do to use syrupy with hypothesis in stateful testing?

Upvotes: 0

Views: 575

Answers (1)

Zac Hatfield-Dodds
Zac Hatfield-Dodds

Reputation: 3003

I think you'll need to ask syrupy to support a non-fixtures interface. From skimming the source this looks technically pretty reasonable; they're mostly using Pytest as source of configuration and for the neat dev experience that fixtures offer. Unfortunately I don't see a way to support fixtures for Hypothesis stateful tests.

I'm surprised that stateful testing could be deterministic enough to take a single stable snapshot; even in deterministic mode we usually run many diverse inputs. Perhaps stateful testing isn't offering you much value here?

Upvotes: 1

Related Questions