Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jul 11, 2023

Conversation

ppisar
Copy link
Contributor

@ppisar ppisar commented Jul 7, 2023

RPM 4.19 removed rpm.fi class. rpmconf tool needs to move to rpm.files class xsuchy/rpmconf#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
Copy link
Contributor Author

ppisar commented Jul 10, 2023

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

@kontura
Copy link
Contributor

kontura commented Jul 10, 2023

Oh I see. I will look into it.

@kontura kontura self-requested a review July 10, 2023 07:42
Copy link
Contributor

@kontura kontura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if also the f38 build was working.

I am not sure if there is a plan to release the new rpmconf also to f38 but maybe given that this is only for tests we could mock both fi and files?
I think if we passed create=True to the fi mock it should work.

RPM 4.19 removed rpm.fi class. rpmconf tool needs to move to rpm.files
class <xsuchy/rpmconf#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
Copy link
Contributor Author

ppisar commented Jul 10, 2023

I added a fallback based on an rpmconf version.

@kontura
Copy link
Contributor

kontura commented Jul 11, 2023

Thanks!

@kontura kontura merged commit f774a4f into rpm-software-management:master Jul 11, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants