An open API service indexing awesome lists of open source software.

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

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 `_