Skip to content

Conversation

@ogayot
Copy link
Member

@ogayot ogayot commented Jan 28, 2026

While rtnetlink unit tests are running fine when using tox (i.e., with modern pyroute2 0.9.x), but running them using pyroute2 from noble/core24 fails in multiple test functions.

It isn't the pyroute2 module itself that is too old, but the mock classes.

@ogayot ogayot marked this pull request as ready for review January 28, 2026 17:47
@ogayot ogayot requested a review from dbungert January 29, 2026 08:14
@ogayot ogayot force-pushed the pyroute2-0.7.11-test branch 2 times, most recently from 41efbba to ef84575 Compare January 29, 2026 10:29
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
@ogayot ogayot force-pushed the pyroute2-0.7.11-test branch from ef84575 to 23f50bb Compare January 29, 2026 10:31
# We need to patch the class, not the instance for some reason.
with mock.patch.object(IPRoute, "fileno", return_value=42):
version_str = importlib.metadata.version("pyroute2")
pyroute2_version = tuple([int(x) for x in version_str.split(".")])
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pyroute2_version = tuple([int(x) for x in version_str.split(".")])
pyroute2_version = tuple(int(x) for x in version_str.split("."))

Just learned that we can do tuple comprehension like this, without the intermediate list

Copy link
Member Author

Choose a reason for hiding this comment

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

TIL, thanks for the suggestion!

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
@ogayot ogayot force-pushed the pyroute2-0.7.11-test branch from 23f50bb to b080bcf Compare February 2, 2026 16:14
@ogayot ogayot merged commit 1001d39 into canonical:main Feb 2, 2026
2 checks passed
@ogayot ogayot deleted the pyroute2-0.7.11-test branch February 2, 2026 16:25
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.

3 participants