rpm-software-management / dnf-plugins-extras

repository for DNF community plugins
GNU General Public License v2.0
65 stars 62 forks source link

Adapt rpmconf tests to RPM 4.19 without rpm.fi #215

Closed ppisar closed 1 year ago

ppisar commented 1 year ago

RPM 4.19 removed rpm.fi class. rpmconf tool needs to move to rpm.files class https://github.com/xsuchy/rpmconf/pull/53. That in turn breaks tests/test_rpmconf.py which mocks rpmconf internals:

tests/test_rpmconf.py:187:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_rpmconf.py:58: in __enter__
    patch.__enter__()
/usr/lib64/python3.12/unittest/mock.py:1455: in __enter__
    original, local = self.get_original()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <unittest.mock._patch object at 0x7fa240b50b00>

    def get_original(self):
        target = self.getter()
        name = self.attribute

        original = DEFAULT
        local = False

        try:
            original = target.__dict__[name]
        except (AttributeError, KeyError):
            original = getattr(target, name, DEFAULT)
        else:
            local = True

        if name in _builtins and isinstance(target, ModuleType):
            self.create = True

        if not self.create and original is DEFAULT:
>           raise AttributeError(
                "%s does not have the attribute %r" % (target, name)
            )
E           AttributeError: <module 'rpm' from '/usr/lib64/python3.12/site-packages/rpm/__init__.py'> does not have the attribute 'fi'

This patch adapts to the changes in rpmconf.

https://bugzilla.redhat.com/show_bug.cgi?id=2219977

ppisar commented 1 year ago

rpmconf moved to rpm.files and released 1.1.10. Now dnf-plugins-extras needs to merge this fix.

kontura commented 1 year ago

Oh I see. I will look into it.

ppisar commented 1 year ago

I added a fallback based on an rpmconf version.

kontura commented 1 year ago

Thanks!