Hi All,
I'm pleased to announce the first release of Sybil, a library to help
you test the examples in your documents.
For example, given the following Sphinx source file:
Sample Documentation
====================
Let's put something in the Sybil document's namespace:
.. invisible-code-block: python
remember_me = b'see how namespaces work?'
Suppose we define a function, convoluted and pointless but shows
stuff nicely:
.. code-block:: python
import sys
def prefix_and_print(message):
print('prefix:', message.decode('ascii'))
Now we can use a doctest REPL to show it in action:
>>> prefix_and_print(remember_me)
prefix: see how namespaces work?
The namespace carries across from example to example, no matter
what parser:
>>> remember_me
b'see how namespaces work?'
All the examples can be tested when using pytest by putting the
following in a conftest.py in your Sphinx source directory:
from doctest import ELLIPSIS
from sybil import Sybil
from sybil.parsers.codeblock import CodeBlockParser
from sybil.parsers.doctest import DocTestParser, FIX_BYTE_UNICODE_REPR
pytest_collect_file = Sybil(
parsers=[
DocTestParser(optionflags=ELLIPSIS|FIX_BYTE_UNICODE_REPR),
CodeBlockParser(future_imports=['print_function']),
],
pattern='*.rst',
).pytest()
The package is on PyPI and a full list of all the links to docs, issue
trackers and the like can be found here:
https://github.com/cjw96/sybil
Any questions, please do ask on the Testing in Python list or on the
Simplistix open source mailing list...
cheers,
Chris
PS: The name comes from Fawlty Towers, as this package is heavily
inspired by Benji York's fantastic Manuel package, which also took it's
name from the series!
--
https://mail.python.org/mailman/listinfo/python-list