Mercurial > kallithea
changeset 8702:8dce5e58eae3
diffs: add doctests for _escaper, also showing incorrect behavior
Add some doctests for the _escaper function.
Note: some tests now show incorrect behavior that will be fixed soon.
author | Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> |
---|---|
date | Tue, 27 Oct 2020 20:29:07 +0100 |
parents | 84d2df525238 |
children | 6bde1c0a04d4 |
files | kallithea/lib/diffs.py |
diffstat | 1 files changed, 38 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/diffs.py Wed Oct 28 16:08:04 2020 +0100 +++ b/kallithea/lib/diffs.py Tue Oct 27 20:29:07 2020 +0100 @@ -449,8 +449,45 @@ def _escaper(diff_line): - """ + r""" Do HTML escaping/markup of a single diff line (including first +/- column) + + >>> _escaper('foobar') + 'foobar' + >>> _escaper('@foo & bar') + '@foo & bar' + >>> _escaper('+foo < bar') + '+foo < bar' + >>> _escaper('-foo > bar') + '-foo > bar' + >>> _escaper(' <foo>') + ' <foo>' + >>> _escaper(' foo\tbar') + ' foo<u>\t</u>bar' + >>> _escaper(' foo\rbar\r') + ' foo<u class="cr"></u>bar<u class="cr"></u>' + >>> _escaper(' foo\t') + ' foo<u>\t</u>' + >>> _escaper(' foo ') + ' foo <i></i>' + >>> _escaper(' foo ') + ' foo <i></i>' + >>> _escaper(' ') + ' ' + >>> _escaper(' ') + ' <i></i>' + >>> _escaper(' \t') + ' <u>\t</u>' + >>> _escaper(' \t ') + ' <u>\t</u> <i></i>' + >>> _escaper(' \t') + ' <u>\t</u>' + >>> _escaper(' \t\t ') + ' <u>\t</u><u>\t</u> <i></i>' + >>> _escaper(' \t\t') + ' <u>\t</u><u>\t</u>' + >>> _escaper(' foo&bar<baz> ') + ' foo&bar<baz> <i></i>' """ def substitute(m):