Commit 9b39f658 authored by Kirill Smelkov's avatar Kirill Smelkov

Detect if .installed.cfg could not be loaded

We need special care because configparser ignores nonexisting arguments
by default.
parent 64514152
...@@ -89,8 +89,10 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo ...@@ -89,8 +89,10 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo
'__buildout_space_v__': '\v', '__buildout_space_v__': '\v',
} }
idb = configparser.ConfigParser(defaults=_) idb = configparser.ConfigParser(defaults=_)
idb.read('%s/.installed.cfg' % installed_software_path) installed_cfg = '%s/.installed.cfg' % installed_software_path
_ = idb.read(installed_cfg)
if not _:
raise RuntimeError("Cannot load %r" % installed_cfg)
for s in idb.sections(): for s in idb.sections():
if s == 'buildout': if s == 'buildout':
......
...@@ -22,7 +22,7 @@ import nxdbom ...@@ -22,7 +22,7 @@ import nxdbom
import pytest import pytest
import os import os
from os.path import dirname from os.path import dirname, exists
@pytest.mark.parametrize('url,nameok,verok', [ @pytest.mark.parametrize('url,nameok,verok', [
...@@ -339,6 +339,14 @@ def test_bom_software(tmpdir, build, bomok): ...@@ -339,6 +339,14 @@ def test_bom_software(tmpdir, build, bomok):
assert nxdbom.fmt_bom(bom) == bomok assert nxdbom.fmt_bom(bom) == bomok
# loading non-existing .installed.cfg -> error
def test_bom_software_eexist():
ne = '/nonexisting'
assert not exists(ne)
with pytest.raises(RuntimeError, match="Cannot load '%s/.installed.cfg'" % ne):
nxdbom.bom_software(ne)
# ---- txtar ---- # ---- txtar ----
# txtar_* provide support for archives in txtar format # txtar_* provide support for archives in txtar format
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment