tests/test-hg-parseurl.py
author Matt Harbison <matt_harbison@yahoo.com>
Fri, 31 Jan 2020 22:20:39 -0500
branchstable
changeset 44148 aab70b540d3d
parent 43076 2372284d9457
child 46908 4452cb788404
permissions -rw-r--r--
resourceutil: account for the non-resource-like file hierarchy under py2exe After 9e367157a990, config files for py2exe were expected to be in C:\Program Files\Mercurial\mercurial\defaultrc because of the implied resource structure of 'mercurial.defaultrc.*.rc', relative to the executable. Accomodating this would require changes to the WIX and Inno scripts (and perhaps the script that generates the WIX script), as well as 3rd party bundlers like TortoiseHg. But these files aren't read as resources anyway- they fall back to the filesystem APIs. (If we really wanted to carry on the charade, the installer would have to also sprinkle various empty __init__.py files around.) Instead, this simply prunes the 'mercurial.' portion of the resource name when run with py2exe. (PyOxidizer uses the resources API, not the filesystem fallback, so it is unaffected.) Since this hack only affects the py2 Windows installers and is less risky, I think it's reasonable. We haven't needed to load any 3rd party resource up to this point, and would have to make packaging changes anyway to handle that. Differential Revision: https://phab.mercurial-scm.org/D8058
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28746
de5808c57f58 py3: use print_function in test-hg-parseurl.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28745
diff changeset
     1
from __future__ import absolute_import, print_function
28806
d26c4af27978 test-hg-parseurl: stop direct symbol import of mercurial.hg.parseurl
Yuya Nishihara <yuya@tcha.org>
parents: 28746
diff changeset
     2
37713
11d128a14ec0 tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents: 28806
diff changeset
     3
import unittest
11d128a14ec0 tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents: 28806
diff changeset
     4
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
     5
from mercurial import hg
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
     6
8174
29bc5d18714a hg: allow hg.parseurl(url, None)
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
     7
37713
11d128a14ec0 tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents: 28806
diff changeset
     8
class ParseRequestTests(unittest.TestCase):
11d128a14ec0 tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents: 28806
diff changeset
     9
    def testparse(self):
8174
29bc5d18714a hg: allow hg.parseurl(url, None)
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
    10
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    11
        self.assertEqual(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    12
            hg.parseurl(b'http://example.com/no/anchor'),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    13
            (b'http://example.com/no/anchor', (None, [])),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    14
        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    15
        self.assertEqual(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    16
            hg.parseurl(b'http://example.com/an/anchor#foo'),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    17
            (b'http://example.com/an/anchor', (b'foo', [])),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    18
        )
37713
11d128a14ec0 tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents: 28806
diff changeset
    19
        self.assertEqual(
37714
5dd71e9ae68a tests: add b prefixes to test-hg-parseurl.py
Augie Fackler <augie@google.com>
parents: 37713
diff changeset
    20
            hg.parseurl(b'http://example.com/no/anchor/branches', [b'foo']),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    21
            (b'http://example.com/no/anchor/branches', (None, [b'foo'])),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    22
        )
37713
11d128a14ec0 tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents: 28806
diff changeset
    23
        self.assertEqual(
37714
5dd71e9ae68a tests: add b prefixes to test-hg-parseurl.py
Augie Fackler <augie@google.com>
parents: 37713
diff changeset
    24
            hg.parseurl(b'http://example.com/an/anchor/branches#bar', [b'foo']),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    25
            (b'http://example.com/an/anchor/branches', (b'bar', [b'foo'])),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    26
        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    27
        self.assertEqual(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    28
            hg.parseurl(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    29
                b'http://example.com/an/anchor/branches-None#foo', None
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    30
            ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    31
            (b'http://example.com/an/anchor/branches-None', (b'foo', [])),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    32
        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    33
        self.assertEqual(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    34
            hg.parseurl(b'http://example.com/'),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    35
            (b'http://example.com/', (None, [])),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    36
        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    37
        self.assertEqual(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    38
            hg.parseurl(b'http://example.com'),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    39
            (b'http://example.com/', (None, [])),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    40
        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    41
        self.assertEqual(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    42
            hg.parseurl(b'http://example.com#foo'),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    43
            (b'http://example.com/', (b'foo', [])),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    44
        )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    45
37713
11d128a14ec0 tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents: 28806
diff changeset
    46
11d128a14ec0 tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents: 28806
diff changeset
    47
if __name__ == '__main__':
11d128a14ec0 tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents: 28806
diff changeset
    48
    import silenttestrunner
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 37714
diff changeset
    49
37713
11d128a14ec0 tests: port test-hg-parseurl.py to unittest
Augie Fackler <augie@google.com>
parents: 28806
diff changeset
    50
    silenttestrunner.main(__name__)