HYPOTHESIS(1)

✨ HYPOTHESIS ✨

okay bestie sit DOWN because this one is genuinely so useful πŸ’– the hypothesis command is a helper tool for property-based testing β€” like, it literally writes and maintains your property-based tests for you in your Python project. no cap. πŸ¦‹


🌸 SYNOPSIS 🌸

hypothesis codemod PATH

hypothesis write [OPTIONS] FUNCTION [FUNCTION ...]

πŸ’… DESCRIPTION πŸ’…

So here's the tea: hypothesis helps you write and maintain property-based tests in your Python project. Two whole modes, both iconic. πŸ‘‘

🧚 hypothesis codemod

This one refactors deprecated or inefficient code, and it rewrites your files in place. Yes, in place. Right there. Where you live. 🫢 It has no additional options β€” it's just built different, no knobs to fiddle with, periodt.

πŸŽ€ hypothesis write

This is the main character. It writes property-based tests for you. Type annotations are helpful but not required (she's flexible like that πŸ’…). Here's every option she recognizes:

  • --roundtrip β€” writes roundtrip tests for write/read or encode/decode functions. like, you know, does the thing survive the trip back? 🌈

Example: hypothesis write --roundtrip json.dumps json.loads

  • --equivalent β€” writes tests checking whether two functions behave identically. twin energy fr fr. πŸ‘―

Example: hypothesis write --equivalent ast.literal_eval eval

  • --errors-equivalent β€” same vibe as --equivalent, but it also allows consistent errors. so if both of them blow up the same way? that counts. 😌
  • --idempotent β€” writes tests checking whether a function is idempotent. do it once, do it a hundred times, same result bestie. ✨
  • --binary-op β€” writes tests for associativity, commutativity and identitiy element. (yes, the manpage says "identitiy" β€” we keep the lore intact. πŸ’€) the math girlies are gonna eat this up.

Example: hypothesis write --binary-op operator.add

  • --except CLASS β€” dotted name of an exception to ignore. can be specified multiple times. stack 'em up. πŸ“
  • --annotate, --no-annotate β€” forces tests to be type-annotated (or NOT). pick your fighter. πŸ™ˆ
  • --style=STYLE β€” writes tests as pytest functions or unittest methods. your aesthetic, your call. πŸ’œ

πŸ‘‘ AUTHORS πŸ‘‘

hypothesis was conceived by David R. McIver and written with the help of many contributors. this manual page was written by Timo Râhling for Debian, and may be reused without restriction. slay of them honestly. 🌸


~ this has been your girl, signing off on version 6.155.7 ~ go write some tests, bestie, you're gonna ate πŸ’–πŸ¦‹βœ¨πŸŽ€πŸ’…

πŸ“¦ where this page comes from