[TIP] Sybil 1.0.0 Released!

Harry Percival harry.percival at gmail.com
Fri May 26 01:02:27 PDT 2017


I did quite a lot of testing for my book about testing. If you're looking
for inspiration for future features, the code is at:

https://github.com/hjwp/Book-TDD-Web-Dev-Python/tree/master/tests

I wanted to be able to:

- parse listings and incomplete listings
- handle state including multiple files, including non-python code
- check that arbitrary terminal commands, if executed in the cumulative
context of the listings so far, actually produce the output the book says
they do (tests and their tracebacks mostly)

I ended up with something that may be a little too specific to my use case,
and a little overengineered, and spaghetti code full of the vestiges of
abandoned dead end approached.  A brief attempt to roll my own
textwrap.textwrap for example.

But still, end results are there. And of course yes there are tests for the
tests of the tests in the testing book.

Happy to talk anyone through any of the code if it's of interest.

Otherwise please just pat me on the back and tell me how smart I am?  ;-)
HP

On Fri, 26 May 2017, 08:43 Chris Withers, <chris at withers.org> wrote:

> 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!
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
>
-- 

--
Harry Percival
+44 78877 02511
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20170526/7ad8e228/attachment.htm>


More information about the testing-in-python mailing list