annotate tests/test-hg-parseurl.py @ 44261:04a3ae7aba14

chg: force-set LC_CTYPE on server start to actual value from the environment Python 3.7+ will "coerce" the LC_CTYPE variable in many instances, and this can cause issues with chg being able to start up. D7550 attempted to fix this, but a combination of a misreading of the way that python3.7 does the coercion and an untested state (LC_CTYPE being set to an invalid value) meant that this was still not quite working. This change will cause differences between chg and hg: hg will have the LC_CTYPE environment variable coerced, while chg will not. This is unlikely to cause any detectable behavior differences in what Mercurial itself outputs, but it does have two known effects: - When using hg, the coerced LC_CTYPE will be passed to subprocesses, even non-python ones. Using chg will remove the coercion, and this will not happen. This is arguably more correct behavior on chg's part. - On macOS, if you set your region to Brazil but your language to English, this isn't representable in locale strings, so macOS sets LC_CTYPE=UTF-8. If this value is passed along when ssh'ing to a non-macOS machine, some functions (such as locale.setlocale()) may raise an exception due to an unsupported locale setting. This is most easily encountered when doing an interactive commit/split/etc. when using ui.interface=curses. Differential Revision: https://phab.mercurial-scm.org/D8039
author Kyle Lippincott <spectral@google.com>
date Wed, 29 Jan 2020 13:39:50 -0800
parents 2372284d9457
children 4452cb788404
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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__)