Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_indexing_toc_entries(fake_addon):
toc_reader = TocReader.from_path_name(fake_addon)
assert toc_reader['Normal'] == ('Normal', 'Normal entry')
assert toc_reader['Compact'] == ('Compact', 'Compact entry')
assert toc_reader['Indented'] == ('Indented', '')
assert toc_reader['Comment'] == ('Comment', '')
assert toc_reader['Nonexistent'] == ('Nonexistent', '')
def test_tabulate(fake_addon):
toc_reader = TocReader.from_path_name(fake_addon)
data = [('key', 'value'), *toc_reader.entries.items()]
assert (
tabulate(data)
== '''\
key value \n\
def test_parsing_toc_entries(fake_addon):
toc_reader = TocReader.from_path_name(fake_addon)
assert toc_reader.entries == {
'Normal': 'Normal entry',
'Compact': 'Compact entry',
}
def test_multiindexing_toc_entries(fake_addon):
toc_reader = TocReader.from_path_name(fake_addon)
assert toc_reader['Normal', 'Compact'] == ('Normal', 'Normal entry')
assert toc_reader['Compact', 'Normal'] == ('Compact', 'Compact entry')
assert toc_reader['Indented', 'Normal'] == ('Normal', 'Normal entry')
assert toc_reader['Nonexistent', 'Indented', 'Normal'] == ('Normal', 'Normal entry')
def test_loading_toc_from_path(fake_addon):
TocReader.from_path(fake_addon / 'FakeAddon.toc')
with pytest.raises(FileNotFoundError):
TocReader.from_path(fake_addon / 'MissingToc.toc')
TocReader.from_path_name(fake_addon)
with pytest.raises(FileNotFoundError):
TocReader.from_path_name(fake_addon.parent / 'MissingAddon')
def get_desc_from_toc(pkg: models.Pkg):
if pkg.source == 'wowi':
toc_reader = TocReader.from_path_name(obj.m.config.addon_dir / pkg.folders[0].name)
return toc_reader['Notes'].value
else:
return pkg.description
def make_addon_folder(path: Path):
if path.name not in own_folders and path.is_dir() and not path.is_symlink():
with suppress(FileNotFoundError):
return AddonFolder(path.name, TocReader.from_path_name(path))