[PATCH 2 of 2] templates/filters: add doctest to the 'person' filter
Yann E. MORIN
yann.morin.1998 at free.fr
Fri Mar 9 09:05:54 UTC 2012
Martin, All,
On Wednesday 07 March 2012 10:43:58 Martin Geisler wrote:
> def person(author):
> - """:person: Any text. Returns the text before an email address."""
> + """:person: Any text. Returns the text before an email address.
> +
> + >>> person('Foo Bar <foo at bar>')
> + 'Foo Bar'
> + """
> if not '@' in author:
This does not work, because then 'hg help templates' prints out the whole
help text, including the doctest. With the above code snippet:
$ ./hg help templates
[--SNIP--]
person Any text. Returns the text before an email address.
>>> person('Foo Bar <foo at bar>') Foo Bar
[--SNIP--]
I'll investigate a bit...
> +import mercurial.templatefilters
> +doctest.testmod(mercurial.templatefilters)
Ah, yes, thanks.
> Doctests are best made by the interactive Python interpreter. A session
> looks like:
>
> % python
> Python 2.7.2+ (default, Nov 30 2011, 19:22:03)
> [GCC 4.6.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from mercurial.templatefilters import person
> >>> person('"Foo \"buz\" Bar" <foo at bar>')
> '"Foo "buz" Bar"'
>
> You can now copy paste the input and output directly.
Woohoo! Thank you! :-)
I'll update the patch and will resend when the test-suite passes.
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
More information about the Mercurial-devel
mailing list