Mercurial > python-hglib
changeset 159:16496e0f3c09
util: update doctests to work with bytes (issue4520)
author | Brett Cannon <brett@python.org> |
---|---|
date | Fri, 27 Mar 2015 12:57:58 -0400 |
parents | 2104fc9aa513 |
children | 91329df47df5 |
files | hglib/util.py |
diffstat | 1 files changed, 23 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/hglib/util.py Fri Mar 27 10:45:26 2015 -0400 +++ b/hglib/util.py Fri Mar 27 12:57:58 2015 -0400 @@ -32,14 +32,14 @@ def eatlines(s, n): """ - >>> eatlines("1\\n2", 1) - '2' - >>> eatlines("1\\n2", 2) - '' - >>> eatlines("1\\n2", 3) - '' - >>> eatlines("1\\n2\\n3", 1) - '2\\n3' + >>> eatlines(b("1\\n2"), 1) == b('2') + True + >>> eatlines(b("1\\n2"), 2) == b('') + True + >>> eatlines(b("1\\n2"), 3) == b('') + True + >>> eatlines(b("1\\n2\\n3"), 1) == b('2\\n3') + True """ cs = BytesIO(s) @@ -53,14 +53,14 @@ """ Skip lines starting with prefix in s - >>> skiplines('a\\nb\\na\\n', 'a') - 'b\\na\\n' - >>> skiplines('a\\na\\n', 'a') - '' - >>> skiplines('', 'a') - '' - >>> skiplines('a\\nb', 'b') - 'a\\nb' + >>> skiplines(b('a\\nb\\na\\n'), b('a')) == b('b\\na\\n') + True + >>> skiplines(b('a\\na\\n'), b('a')) == b('') + True + >>> skiplines(b(''), b('a')) == b('') + True + >>> skiplines(b('a\\nb'), b('b')) == b('a\\nb') + True """ cs = BytesIO(s) @@ -174,17 +174,22 @@ """ Decorator that remembers the return value of a function call. + >>> execcount = 0 >>> class obj(object): ... def func(self): - ... print 'func' + ... global execcount + ... execcount += 1 ... return [] ... func = propertycache(func) >>> o = obj() >>> o.func - func [] + >>> execcount + 1 >>> o.func [] + >>> execcount + 1 """ def __init__(self, func): self.func = func