# HG changeset patch # User Thomas De Schampheleire # Date 2020-10-27 20:29:07 # Node ID 8dce5e58eae3f86a2b2c0f302cc9ec4fd90fdf2f # Parent 84d2df525238934eca4357b080dce3a72ace7444 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. diff --git a/kallithea/lib/diffs.py b/kallithea/lib/diffs.py --- a/kallithea/lib/diffs.py +++ b/kallithea/lib/diffs.py @@ -449,8 +449,45 @@ _escape_re = re.compile(r'(&)|(<)|(>)|(\ 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>' + >>> _escaper(' foo\tbar') + ' foo\tbar' + >>> _escaper(' foo\rbar\r') + ' foobar' + >>> _escaper(' foo\t') + ' foo\t' + >>> _escaper(' foo ') + ' foo ' + >>> _escaper(' foo ') + ' foo ' + >>> _escaper(' ') + ' ' + >>> _escaper(' ') + ' ' + >>> _escaper(' \t') + ' \t' + >>> _escaper(' \t ') + ' \t ' + >>> _escaper(' \t') + ' \t' + >>> _escaper(' \t\t ') + ' \t\t ' + >>> _escaper(' \t\t') + ' \t\t' + >>> _escaper(' foo&bar ') + ' foo&bar<baz> ' """ def substitute(m):