[PATCH 1 of 2] templatefilters: add doctests for person
Adrian Buehlmann
adrian at cadifra.com
Sun Apr 17 15:32:34 CDT 2011
# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1303068865 -7200
# Node ID 989a7f3abceb143a547f17e7520863d8124052f1
# Parent d66272d05c8ab8dd4dd6f392d2e5820d7c417db8
templatefilters: add doctests for person
diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py
--- a/mercurial/templatefilters.py
+++ b/mercurial/templatefilters.py
@@ -241,7 +241,12 @@
return "-rw-r--r--"
def person(author):
- """:person: Any text. Returns the text before an email address."""
+ """:person: Any text. Returns the text before an email address.
+ >>> person('John Doe <john at example.com>')
+ 'John Doe'
+ >>> person('john.doe at example.com')
+ 'john'
+ """
if not '@' in author:
return author
f = author.find('<')
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -194,7 +194,9 @@
# template engine
path = ['templates', '../templates']
-stringify = templatefilters.stringify
+
+def stringify(x):
+ return templatefilters.stringify(x)
def _flatten(thing):
'''yield a single stream from a possibly nested set of iterators'''
diff --git a/tests/test-doctest.py b/tests/test-doctest.py
--- a/tests/test-doctest.py
+++ b/tests/test-doctest.py
@@ -13,6 +13,9 @@
import mercurial.match
doctest.testmod(mercurial.match)
+import mercurial.templatefilters
+doctest.testmod(mercurial.templatefilters)
+
import mercurial.url
doctest.testmod(mercurial.url)
More information about the Mercurial-devel
mailing list