https://github.com/cthoyt/hypothesis-ebnf
A Hypothesis strategy for generating sentences from an EBNF grammar
https://github.com/cthoyt/hypothesis-ebnf
Last synced: about 2 months ago
JSON representation
A Hypothesis strategy for generating sentences from an EBNF grammar
- Host: GitHub
- URL: https://github.com/cthoyt/hypothesis-ebnf
- Owner: cthoyt
- License: mit
- Created: 2018-08-06T08:42:32.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-29T15:32:44.000Z (over 6 years ago)
- Last Synced: 2025-01-22T16:24:57.774Z (4 months ago)
- Language: Python
- Size: 8.79 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
Hypothesis-EBNF
===============
A Hypothesis strategy for generating sentences from an EBNF grammar.Can be imported like any other strategy, and used in the ``given()`` annotation with Hypothesis tests.
.. code-block:: python
# third-party
from hypothesis import given
from nltk.parse.generate import demo_grammar# code from this repository
from hypothesis_ebnf import ebnf@given(sentence=ebnf(demo_grammar))
def test_demo_grammar(sentence):
"""Use the demo grammar from NLTK to make some test cases."""
print(sentence)
assert isinstance(sentence, str)Installation
------------
This code can currently be installed via GitHub with:.. code-block:: bash
$ python3 -m pip install git+https://github.com/cthoyt/hypothesis-ebnf.git@master
Once it's tested better, it will be put on PyPI.
Acknowledgements and References
-------------------------------
- `Hypothesis `_
- `Natural Language Toolkit `_