tests/test-hg-parseurl.py
author Arseniy Alekseyev <aalekseyev@janestreet.com>
Fri, 12 Apr 2024 16:09:45 +0100
branchstable
changeset 51570 b39057b713b1
parent 48875 6000f5b25c9b
permissions -rw-r--r--
match: fix the rust-side bug in visit_children_set for rootfilesin matchers The fix is checked by `test_pattern_matcher_visit_children_set` test, which is what caught the bug in the first place, but also by an end-to-end test that I made for this purpose. Accept the new results of Cargo tests Many of these were already annotated with "FIXME", which is a good sign.

import unittest

from mercurial.utils import urlutil


class ParseRequestTests(unittest.TestCase):
    def testparse(self):

        self.assertEqual(
            urlutil.parseurl(b'http://example.com/no/anchor'),
            (b'http://example.com/no/anchor', (None, [])),
        )
        self.assertEqual(
            urlutil.parseurl(b'http://example.com/an/anchor#foo'),
            (b'http://example.com/an/anchor', (b'foo', [])),
        )
        self.assertEqual(
            urlutil.parseurl(
                b'http://example.com/no/anchor/branches', [b'foo']
            ),
            (b'http://example.com/no/anchor/branches', (None, [b'foo'])),
        )
        self.assertEqual(
            urlutil.parseurl(
                b'http://example.com/an/anchor/branches#bar', [b'foo']
            ),
            (b'http://example.com/an/anchor/branches', (b'bar', [b'foo'])),
        )
        self.assertEqual(
            urlutil.parseurl(
                b'http://example.com/an/anchor/branches-None#foo', None
            ),
            (b'http://example.com/an/anchor/branches-None', (b'foo', [])),
        )
        self.assertEqual(
            urlutil.parseurl(b'http://example.com/'),
            (b'http://example.com/', (None, [])),
        )
        self.assertEqual(
            urlutil.parseurl(b'http://example.com'),
            (b'http://example.com/', (None, [])),
        )
        self.assertEqual(
            urlutil.parseurl(b'http://example.com#foo'),
            (b'http://example.com/', (b'foo', [])),
        )


if __name__ == '__main__':
    import silenttestrunner

    silenttestrunner.main(__name__)