-
Notifications
You must be signed in to change notification settings - Fork 345
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
Fix apt unit tests #6029
Closed
Closed
Fix apt unit tests #6029
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,12 +13,26 @@ def apt_supported_distro(): | |
return distro.detect().name in ["debian", "Ubuntu"] | ||
|
||
|
||
def login_binary_path(distro_name, distro_version): | ||
"""Retrieve the login binary path based on the distro version"""" | ||
if distro_name == "Ubuntu": | ||
if float(distro_version) >= 24.04: | ||
return "/usr/bin/login" | ||
if distro_name == "debian": | ||
if distro_version == "trixie": | ||
return "/usr/bin/login" | ||
return "/bin/login" | ||
|
||
|
||
@unittest.skipUnless(os.getuid() == 0, "This test requires root privileges") | ||
@unittest.skipUnless(apt_supported_distro(), "Unsupported distro") | ||
class Apt(unittest.TestCase): | ||
def test_provides(self): | ||
sm = manager.SoftwareManager() | ||
self.assertEqual(sm.provides("/bin/login"), "login") | ||
distro_name = distro.detect().name | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And optimization here to avoid calling the detection twice: detected = distro.detect()
login_path = login_binary_path(detected.name, detected.version) Also, it would be OK to change |
||
distro_version = distro.detect().version | ||
login_path = login_binary_path(distro_name, distro_version) | ||
self.assertEqual(sm.provides(login_path), "login") | ||
self.assertTrue(isinstance(sm.backend, backends.apt.AptBackend)) | ||
|
||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ties into my previous point. It's very probably that
unstable
also has the file at the same place astesting
, right? In the future, when those are released, it'd make sense to do a numerical version comparison IMO.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, this should be "
sid
or >= 14". When trixie is released later this year, it will revert to version 14 in/etc/debian_version
, and will be replaced withforky
for thetesting
releasetrixie
==testing
<== the codename changes depending on the next releasesid
==unstable
<== This is always the sameWhen stuff is uploaded to Debian, it's always done to
unstable
, and when the tests pass, it migrates totesting
. So, it's important that we detect both trixie and sid imho