{"id":15440415,"url":"https://github.com/zac-hd/hypothesis-workshop","last_synced_at":"2025-04-19T20:45:17.830Z","repository":{"id":98812517,"uuid":"135460686","full_name":"Zac-HD/hypothesis-workshop","owner":"Zac-HD","description":"Tutorial and links for Pycon Asia-Pacific workshop","archived":false,"fork":false,"pushed_at":"2018-08-27T22:47:13.000Z","size":8,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T13:12:15.670Z","etag":null,"topics":["hypothesis","pycon","tutorial"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zac-HD.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-30T15:11:34.000Z","updated_at":"2021-05-08T17:10:10.000Z","dependencies_parsed_at":"2023-03-13T15:54:27.702Z","dependency_job_id":null,"html_url":"https://github.com/Zac-HD/hypothesis-workshop","commit_stats":{"total_commits":7,"total_committers":3,"mean_commits":"2.3333333333333335","dds":0.2857142857142857,"last_synced_commit":"8d415d90b9dc205a2ad25155bcdadc79b834b8e5"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zac-HD%2Fhypothesis-workshop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zac-HD%2Fhypothesis-workshop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zac-HD%2Fhypothesis-workshop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zac-HD%2Fhypothesis-workshop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zac-HD","download_url":"https://codeload.github.com/Zac-HD/hypothesis-workshop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249795738,"owners_count":21326780,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hypothesis","pycon","tutorial"],"created_at":"2024-10-01T19:13:16.791Z","updated_at":"2025-04-19T20:45:17.802Z","avatar_url":"https://github.com/Zac-HD.png","language":"Python","readme":"# An Interactive Introduction to Hypothesis\n\n*This tutorial was written for Pycon Asia-Pacific 2018, in Singapore.*\n\n\n[Hypothesis](https://hypothesis.readthedocs.io) is a library for property-based testing.\nIn short:\n\n1. You write a parametrised test.\n2. Instead of (or as well as) providing a list of specific inputs to test,\n   you describe what a valid input *is*.\n3. Hypothesis tries hundreds of inputs, and reports the smallest possible\n   example that makes your tests fail.\n4. Failing examples are saved to disk and will be checked next time,\n   so your build stays broken or the bug stays fixed.\n\nThe core algorithm is essentially a smart, coverage-guided fuzzing tool,\nwhich is *really* powerful when pointed at a test with assertions about correct behaviour.\nFor the sake of time, today we're just going to use it for unit testing.\n\n(There are plenty of other use-cases, from checking that your web API matches\nthe schema to writing an adversarial scheduler to test a concurrent program.\nThis tutorial is just an introduction to the most common uses, so come talk to\nme or get in touch later if you're interested in advanced uses.\nThat includes anyone who reads this, even if you're not at Pycon!)\n\n\n## Setup\n\nClone this repository, so you have a local copy of all the code, then run\n\n    pip install pytest hypothesis\n\nto install the dependencies.\n\nThat's it!  Hypothesis works on every current version of Python\n(at time of writing, that's 2.7 and 3.4+; we always match upstream)\nand every test runner that we know of including the standard library\n`unittest`, though I recommend `pytest` for both beginners and experts.\n\n\n## Tutorial\n\nOpen a terminal in this directory (and virtualenv if you used one), and run\n\n    pytest workshop.py\n\nThe tests should pass.  Now, open `workshop.py` in your preferred editor.\nTry to fix the `# TODO` comments in each section, and run the tests\nregularly to make sure it's working.  Once you're happy with both tests\nand features, you're done with this part of the workshop!\n\nIf you're stuck, or just curious about how else you could've solved these\nproblems, there is a [**spoilers branch**](../../tree/spoilers) containing solutions.\n\nYou should now have a decent idea of how to use Hypothesis, and the benefits\nit can deliver for your code (and your tests).\n\n\n## The next step\n\nThis is a good place to stop if you'd like to move on to another workshop.\nIf you want to keep going, you could:\n\n* Try a harder problem from [David's all-day workshop](https://github.com/DRmacIver/hypothesis-training).\n  These are small but tricky functions that give you useful experience\n  in working out what kind of property-based tests will be useful.\n\n* Bring some real code that you want to test, and apply Hypothesis to it!\n  Talk to Zac in person for specific suggestions on how to test your code\n  and/or feedback on tests you've written.\n  (or contact me later; assistance is free for open source\n  and reasonably priced for proprietary projects)\n\n* Contribute to Hypothesis itself!  [We have plenty of starter issues](https://github.com/HypothesisWorks/hypothesis-python/labels/good%20first%20issue),\n  and actively mentor new contributors - which is even better in person.\n  You don't need any previous experience to make a useful contribution!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzac-hd%2Fhypothesis-workshop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzac-hd%2Fhypothesis-workshop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzac-hd%2Fhypothesis-workshop/lists"}