-
Notifications
You must be signed in to change notification settings - Fork 575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Easier way to check RuleBasedStateMachine
invariants only when fully initialized
#2868
Comments
If anything I’m leaning the other way at the moment. I’m struggling to imagine a realistic use case for checking invariants during partial init. Even in cases where it would be useful, we’d still check invariants after all initializers complete successfully, so the worst case is that we fail slightly later than we otherwise would have. |
After #2883 is merged, I'll open a PR for this issue from Zac-HD/hypothesis@multiple-preconditions...init-then-invariants. |
When using stateful testing,
@invariant()
methods are currently checked between every@initialize()
method as well as between@rule()
methods - which is awkward if your invariants require the machine to be initialized (see #2860 for discussion).Instead of requiring users to use
@precondition()
decorators and track the "fully initialized" state themselves, I propose that we should add a new argument to the invariant decorator:to make disabling this behaviour on a per-invariant basis more convenient.
Contra #2860, I think we should retain the existing (always check invariants) behaviour by default - our API style guide emphasises avoiding things that can lead to "unexpectedly weak tests". I'm open to suggestions for a better parameter name, with the goal that it should be very obvious than
@invariant(argname=True)
is checked both before and after whileFalse
is only checked after.The text was updated successfully, but these errors were encountered: