Mercurial > hg-stable
view tests/test-mdiff.py @ 42705:f95b59ffc307
byteify-strings: add --treat-as-kwargs argument to handle kwargs-like objects
This argument will help extensions move to Python 3 as keyword arguments
should not be byte-prefixed. Most of the time, code bases will call this
object `kwargs`, but other conventions exist like `opts`, so it should make
sense to allow for custom names.
This is a best effort solution that does minimal static checking; cases like
`options = [o for o in ('a', 'b', 'c') if kwargs.get(o)]`
and other just as complicated will not be detected.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Fri, 02 Aug 2019 10:18:22 +0200 |
parents | 8d0b0b533e09 |
children | 2372284d9457 |
line wrap: on
line source
from __future__ import absolute_import from __future__ import print_function import unittest from mercurial import ( mdiff, ) class splitnewlinesTests(unittest.TestCase): def test_splitnewlines(self): cases = {b'a\nb\nc\n': [b'a\n', b'b\n', b'c\n'], b'a\nb\nc': [b'a\n', b'b\n', b'c'], b'a\nb\nc\n\n': [b'a\n', b'b\n', b'c\n', b'\n'], b'': [], b'abcabc': [b'abcabc'], } for inp, want in cases.items(): self.assertEqual(mdiff.splitnewlines(inp), want) if __name__ == '__main__': import silenttestrunner silenttestrunner.main(__name__)