forked from mirrors/gecko-dev
ManifestParser will read TOML files, if present, when use_toml=True Added tomlkit as a third_party python package Added poetry-core and tomlkit to pypi (separately as Bug 1845383, Bug 1844787) Adds TOML test coverage Adds tomlkit as a dependency of mozharness (in test_archive.py) Added tomlkit to virtualenv_modules in testing/mozharness/configs/unittests Removes dependency on six testing/tools/mach_test_package_initialize.py - Corrected SEARCH_PATHS testing/mozharness/mozharness/mozilla/testing/per_test_base.py - moved `from manifestparser import TestManifest` into function call to avoid harness inability to locate the internal artifact - Removed linter warnings testing/mozbase/manifestparser/manifestparser/manifestparser.py - Removed linter warnings - Updated logger usage pattern - Simplifed _read logic, refactored get_fp_filename() - Improve context for `include:` logging message - Defer `import mozlog` until the point of use testing/mozbase/manifestparser/manifestparser/toml.py - Removed linter warnings - Removed unused logger - Improved readability of read_toml() testing/mozbase/manifestparser/manifestparser/ini.py - Removed linter warnings - Removed unused logger testing/mozbase/manifestparser/manifestparser/filters.py - Removed linter warnings testing/mozbase/manifestparser/tests/test_chunking.py - Removed linter warnings Bumped manifestparser version to 2.2.31 Differential Revision: https://phabricator.services.mozilla.com/D184020
104 lines
2.3 KiB
Python
104 lines
2.3 KiB
Python
#!/usr/bin/env python
|
|
|
|
"""
|
|
Test how our utility functions are working.
|
|
"""
|
|
|
|
from io import StringIO
|
|
from textwrap import dedent
|
|
|
|
import mozunit
|
|
import pytest
|
|
from manifestparser import read_ini
|
|
from manifestparser.util import evaluate_list_from_string
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def parse_manifest():
|
|
def inner(string, **kwargs):
|
|
buf = StringIO()
|
|
buf.write(dedent(string))
|
|
buf.seek(0)
|
|
return read_ini(buf, **kwargs)[0]
|
|
|
|
return inner
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"test_manifest, expected_list",
|
|
[
|
|
[
|
|
"""
|
|
[test_felinicity.py]
|
|
kittens = true
|
|
cats =
|
|
"I",
|
|
"Am",
|
|
"A",
|
|
"Cat",
|
|
""",
|
|
["I", "Am", "A", "Cat"],
|
|
],
|
|
[
|
|
"""
|
|
[test_felinicity.py]
|
|
kittens = true
|
|
cats =
|
|
["I", 1],
|
|
["Am", 2],
|
|
["A", 3],
|
|
["Cat", 4],
|
|
""",
|
|
[
|
|
["I", 1],
|
|
["Am", 2],
|
|
["A", 3],
|
|
["Cat", 4],
|
|
],
|
|
],
|
|
],
|
|
)
|
|
def test_string_to_list_conversion(test_manifest, expected_list, parse_manifest):
|
|
parsed_tests = parse_manifest(test_manifest)
|
|
assert evaluate_list_from_string(parsed_tests[0][1]["cats"]) == expected_list
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"test_manifest, failure",
|
|
[
|
|
[
|
|
"""
|
|
# This will fail since the elements are not enlosed in quotes
|
|
[test_felinicity.py]
|
|
kittens = true
|
|
cats =
|
|
I,
|
|
Am,
|
|
A,
|
|
Cat,
|
|
""",
|
|
ValueError,
|
|
],
|
|
[
|
|
"""
|
|
# This will fail since the syntax is incorrect
|
|
[test_felinicity.py]
|
|
kittens = true
|
|
cats =
|
|
["I", 1,
|
|
["Am", 2,
|
|
["A", 3],
|
|
["Cat", 4],
|
|
""",
|
|
SyntaxError,
|
|
],
|
|
],
|
|
)
|
|
def test_string_to_list_conversion_failures(test_manifest, failure, parse_manifest):
|
|
parsed_tests = parse_manifest(test_manifest)
|
|
with pytest.raises(failure):
|
|
evaluate_list_from_string(parsed_tests[0][1]["cats"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
mozunit.main()
|