Mercurial > hg
view tests/test-config-parselist.py @ 49781:f4a363b25859 stable
extensions: load help from hgext.__index__ as a fallback this time
Prior to 843418dc0b1b, `hgext.__index__` was consulted first if present, which
caused the longer help from the extension modules to be ignored, even when
available. But that change causes a bunch of test failures when the pyoxidized
binary bundles *.pyc in the binary, saying the there's no help topic for
`hg help $disabled_extension` and suggesting the use of `--keyword`, rather than
showing a summary and indicating that it is disabled. Current failures were in
test-check-help.t, test-extension.t, test-help.t, and test-qrecord.t.
Ideally, we would read the various *.pyc files from memory and slurp in the
docstring, but I know that they used to not be readable as resources, and I
can't figure out how to make it work now. So maybe 3.9 and/or the current
PyOxidizer doesn't support it yet. I got closer in py2exe with
`importlib.resources.open_binary("hgext", "rebase.pyc")`, but `open_binary()` on
*.pyc fails in pyoxidizer.[1] Either way, the *.pyc can't be passed to
`ast.parse()` as `extensions._disabledcmdtable()` is doing, so I'm setting that
aside for now.
[1] https://github.com/indygreg/PyOxidizer/issues/649
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 05 Dec 2022 16:05:04 -0500 |
parents | 6961eca0b3ee |
children |
line wrap: on
line source
""" List-valued configuration keys have an ad-hoc microsyntax. From `hg help config`: > List values are separated by whitespace or comma, except when values are > placed in double quotation marks: > > allow_read = "John Doe, PhD", brian, betty > > Quotation marks can be escaped by prefixing them with a backslash. Only > quotation marks at the beginning of a word is counted as a quotation > (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``). That help documentation is fairly light on details, the actual parser has many other edge cases. This test tries to cover them. """ from mercurial.utils import stringutil def assert_parselist(input, expected): result = stringutil.parselist(input) if result != expected: raise AssertionError( "parse_input(%r)\n got %r\nexpected %r" % (input, result, expected) ) # Keep these Python tests in sync with the Rust ones in `rust/hg-core/src/config/values.rs` assert_parselist(b'', []) assert_parselist(b',', []) assert_parselist(b'A', [b'A']) assert_parselist(b'B,B', [b'B', b'B']) assert_parselist(b', C, ,C,', [b'C', b'C']) assert_parselist(b'"', [b'"']) assert_parselist(b'""', [b'', b'']) assert_parselist(b'D,"', [b'D', b'"']) assert_parselist(b'E,""', [b'E', b'', b'']) assert_parselist(b'"F,F"', [b'F,F']) assert_parselist(b'"G,G', [b'"G', b'G']) assert_parselist(b'"H \\",\\"H', [b'"H', b',', b'H']) assert_parselist(b'I,I"', [b'I', b'I"']) assert_parselist(b'J,"J', [b'J', b'"J']) assert_parselist(b'K K', [b'K', b'K']) assert_parselist(b'"K" K', [b'K', b'K']) assert_parselist(b'L\tL', [b'L', b'L']) assert_parselist(b'"L"\tL', [b'L', b'', b'L']) assert_parselist(b'M\x0bM', [b'M', b'M']) assert_parselist(b'"M"\x0bM', [b'M', b'', b'M']) assert_parselist(b'"N" , ,"', [b'N"']) assert_parselist(b'" ,O, ', [b'"', b'O'])