[TESTS] parse_record returns a list of strings instead of BuildrootPaths

Because the output is directly stored to JSON file.
This commit is contained in:
Lumir Balhar 2020-09-23 06:06:53 +02:00 committed by churchyard
parent a5cf74fc41
commit 228f3947df
2 changed files with 20 additions and 21 deletions

View File

@ -43,14 +43,13 @@ def parse_record(record_path, record_content):
(it can also be absolute according to the standard, but not from pip)
Examples:
>>> parse_record(BuildrootPath('/usr/lib/python3.7/site-packages/requests-2.22.0.dist-info/RECORD'),
... [('requests/sessions.py', 'sha256=xxx', '666')])
['/usr/lib/python3.7/site-packages/requests/sessions.py']
>>> next(parse_record(BuildrootPath('/usr/lib/python3.7/site-packages/requests-2.22.0.dist-info/RECORD'),
... [('requests/sessions.py', 'sha256=xxx', '666'), ...]))
BuildrootPath('/usr/lib/python3.7/site-packages/requests/sessions.py')
>>> next(parse_record(BuildrootPath('/usr/lib/python3.7/site-packages/tldr-0.5.dist-info/RECORD'),
... [('../../../bin/tldr', 'sha256=yyy', '777'), ...]))
BuildrootPath('/usr/bin/tldr')
>>> parse_record(BuildrootPath('/usr/lib/python3.7/site-packages/tldr-0.5.dist-info/RECORD'),
... [('../../../bin/tldr', 'sha256=yyy', '777')])
['/usr/bin/tldr']
"""
sitedir = record_path.parent.parent # trough the dist-info directory
# / with absolute right operand will remove the left operand

View File

@ -123,17 +123,17 @@ def test_parse_record_tldr():
output = list(parse_record(record_path, record_content))
pprint(output)
expected = [
BINDIR / "__pycache__/tldr.cpython-37.pyc",
BINDIR / "tldr",
BINDIR / "tldr.py",
SITELIB / "__pycache__/tldr.cpython-37.pyc",
SITELIB / "tldr-0.5.dist-info/INSTALLER",
SITELIB / "tldr-0.5.dist-info/LICENSE",
SITELIB / "tldr-0.5.dist-info/METADATA",
SITELIB / "tldr-0.5.dist-info/RECORD",
SITELIB / "tldr-0.5.dist-info/WHEEL",
SITELIB / "tldr-0.5.dist-info/top_level.txt",
SITELIB / "tldr.py",
str(BINDIR / "__pycache__/tldr.cpython-37.pyc"),
str(BINDIR / "tldr"),
str(BINDIR / "tldr.py"),
str(SITELIB / "__pycache__/tldr.cpython-37.pyc"),
str(SITELIB / "tldr-0.5.dist-info/INSTALLER"),
str(SITELIB / "tldr-0.5.dist-info/LICENSE"),
str(SITELIB / "tldr-0.5.dist-info/METADATA"),
str(SITELIB / "tldr-0.5.dist-info/RECORD"),
str(SITELIB / "tldr-0.5.dist-info/WHEEL"),
str(SITELIB / "tldr-0.5.dist-info/top_level.txt"),
str(SITELIB / "tldr.py"),
]
assert output == expected
@ -149,9 +149,9 @@ def test_parse_record_tensorflow():
output = list(parse_record(record_path, record_content))
pprint(output)
expected = [
BINDIR / "toco_from_protos",
SITELIB / long,
SITEARCH / "tensorflow-2.1.0.dist-info/METADATA",
str(BINDIR / "toco_from_protos"),
str(SITELIB / long),
str(SITEARCH / "tensorflow-2.1.0.dist-info/METADATA"),
]
assert output == expected