https://github.com/psypherpunk/hypothesis-blns
Provides a Hypothesis strategy for generating values from the Big List of Naughty Strings.
https://github.com/psypherpunk/hypothesis-blns
Last synced: 8 months ago
JSON representation
Provides a Hypothesis strategy for generating values from the Big List of Naughty Strings.
- Host: GitHub
- URL: https://github.com/psypherpunk/hypothesis-blns
- Owner: PsypherPunk
- License: mit
- Created: 2022-09-17T14:52:19.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-17T14:56:54.000Z (almost 4 years ago)
- Last Synced: 2025-01-24T12:13:57.394Z (over 1 year ago)
- Language: Python
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `hypothesis-blns`
## Why?
Inspired by the many talks and workshops at
[PyCon UK 2022](https://2022.pyconuk.org/) covering
[*Hypothesis*](https://hypothesis.readthedocs.io/).
## What?
Hypothesis already has a
[`text()`](https://hypothesis.readthedocs.io/en/latest/data.html#hypothesis.strategies.text)
strategy which will generate strings for testing. The
[Big List of Naughty Strings](https://github.com/minimaxir/big-list-of-naughty-strings/)
provides a specific set of notorious strings which can be useful in testing
assumptions around the stability of a functions handling of strings.
## How?
```python
from hypothesis import given, strategies
from hypothesis_blns.strategies import blns
def should_handle_strings_sensibly(input: str) -> str:
...
@given(blns())
def test_blns(naughty: str):
result = should_handle_strings_sensibly(naughty)
...
```
## Really?
Yeah, in hindsight throwing the whole set through a function via
[`@pytest.mark.parametrize`](https://docs.pytest.org/en/6.2.x/parametrize.html)
or similar would make more sense: there aren't that many values.
Oh well…