Skip to content

Skipping test_permission_error if runner is root. #502

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

Merged
merged 4 commits into from
May 19, 2025

Conversation

ZiadAmerr
Copy link

This fixes:

I have added a check or os.getuid() == 0 to the skipping condition of the test to make sure it is skipped when running as root.

@Copilot Copilot AI review requested due to automatic review settings May 19, 2025 17:05
@github-actions github-actions bot added the tests label May 19, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the skip condition on the test_permission_error test to also skip execution when the tests are running as root.

  • Updated skipif condition in the test to include "os.getuid() == 0"
  • Adjusted the reason message to reflect the change

@@ -99,7 +99,8 @@ async def test_missing_file_error(self, temp_file: Path):
await resource.read()

@pytest.mark.skipif(
os.name == "nt", reason="File permissions behave differently on Windows"
os.name == "nt" or os.getuid() == 0,
Copy link
Preview

Copilot AI May 19, 2025

Choose a reason for hiding this comment

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

Consider using hasattr(os, 'getuid') or similar guards to ensure os.getuid() is only accessed on platforms where it is defined, improving code clarity and maintainability.

Suggested change
os.name == "nt" or os.getuid() == 0,
os.name == "nt" or (hasattr(os, 'getuid') and os.getuid() == 0),

Copilot uses AI. Check for mistakes.

@ZiadAmerr
Copy link
Author

All tests pass now :)

@ZiadAmerr ZiadAmerr requested a review from Copilot May 19, 2025 17:16
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes issue #501 by ensuring that the test_permission_error test is skipped when running on Windows or as the root user.

  • Updated skip condition in test_permission_error to include a check for os.getuid() being 0.
  • Modified the reason message to reflect the updated condition.

Copy link
Collaborator

@zzstoatzz zzstoatzz left a comment

Choose a reason for hiding this comment

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

for posterity @ZiadAmerr do you mind sharing your motivation for running tests as root? this seems fine to me though

@zzstoatzz zzstoatzz merged commit de708de into jlowin:main May 19, 2025
4 checks passed
@ZiadAmerr
Copy link
Author

Hi @zzstoatzz. It was actually a complete coincidence. I had pulled the repo and ran the tests after I was using root for other stuff. Mere coincidence.

@ZiadAmerr ZiadAmerr deleted the fix-test-permission-error branch May 20, 2025 07:15
@ZiadAmerr

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants