tests/test-mdiff.py
author Arseniy Alekseyev <aalekseyev@janestreet.com>
Fri, 26 Apr 2024 19:10:35 +0100
changeset 51626 865efc020c33
parent 48875 6000f5b25c9b
permissions -rw-r--r--
dirstate: remove the python-side whitelist of allowed matchers This whitelist is too permissive because it allows matchers that contain disallowed ones deep inside, for example through `intersectionmatcher`. It is also too restrictive because it doesn't pass through some of the matchers we support, such as `patternmatcher`. It's also unnecessary because unsupported matchers raise `FallbackError` and we fall back anyway. Making this change makes more of the tests use rust code path, and therefore subtly change behavior. For example, rust status in largefiles repos seems to have strange behavior.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35862
1ab7b16c9437 tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff changeset
     1
import unittest
1ab7b16c9437 tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff changeset
     2
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36328
diff changeset
     3
from mercurial import mdiff
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36328
diff changeset
     4
35862
1ab7b16c9437 tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff changeset
     5
1ab7b16c9437 tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff changeset
     6
class splitnewlinesTests(unittest.TestCase):
1ab7b16c9437 tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff changeset
     7
    def test_splitnewlines(self):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36328
diff changeset
     8
        cases = {
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36328
diff changeset
     9
            b'a\nb\nc\n': [b'a\n', b'b\n', b'c\n'],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36328
diff changeset
    10
            b'a\nb\nc': [b'a\n', b'b\n', b'c'],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36328
diff changeset
    11
            b'a\nb\nc\n\n': [b'a\n', b'b\n', b'c\n', b'\n'],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36328
diff changeset
    12
            b'': [],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36328
diff changeset
    13
            b'abcabc': [b'abcabc'],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36328
diff changeset
    14
        }
36327
58c1368ab629 py3: use dict.items() instead of dict.iteritems() in tests
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35862
diff changeset
    15
        for inp, want in cases.items():
35862
1ab7b16c9437 tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff changeset
    16
            self.assertEqual(mdiff.splitnewlines(inp), want)
1ab7b16c9437 tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff changeset
    17
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36328
diff changeset
    18
35862
1ab7b16c9437 tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff changeset
    19
if __name__ == '__main__':
1ab7b16c9437 tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff changeset
    20
    import silenttestrunner
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 36328
diff changeset
    21
35862
1ab7b16c9437 tests: start a set of unit tests for mdiff.py, starting with splitnewlines
Augie Fackler <augie@google.com>
parents:
diff changeset
    22
    silenttestrunner.main(__name__)