-
Notifications
You must be signed in to change notification settings - Fork 22
Added test for test_util to ensure file absence when open for reading #1794
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
Conversation
ilyas829
commented
Oct 2, 2024
- I have added a pytest function to ensure file absence when open for reading.
- It basically for below purpose
- Creates a file
- Open the file for reading and
- Ensures that the file is removed
- Please review my PR and merge it
- also suggest your valuable feedback.
@ilyas829 thanks for your contribution. could you please run "poetry run ruff format" before submitting ? you could amend the commit. since you're only adding testcases, is the only purpose to increase test coverage or did you find a real issue somewhere? |
Thank you for reviewing my test coverage codes.. Yes the purpose of appending test cases were to increase test coverage but I din not found any issue as i wrote and tested these cases, but now I am moving up in the hierarchy and find errors or bugs in the test_user, test_services and so on. |
Thanks. basically your new test is a duplicate of https://github.com/SUSE/BCI-dockerfile-generator/pull/1794/files#diff-0dcbadaa6c70afb6fea041dec04bb89c3cc7fe201fb7c3185a669efa49769f28R10-R16 . the fact that you can read a file after creating it is not super useful given that the purpose of this unit test is to validate that "ensure_absent" works. Given that you confirmed that this isn't testing for a real issue, I would actually not be in favor of adding this test. if you can find a combination of file / directory / permission creation where ensure_absent breaks and you write a test for that, that would be awesome as a contribution. |
Perfect, 1st of all Thank you for describing the required test case. Yes we can do that.
The code for the same is just pushed and please review and suggest your valuable feedback |
Hey @dirkmueller please can you check as it this condition is working for me.. |
@dcermak should we fix ensure_absent to handle permission errors like this rather than raising an exception? |
os.chmod(path, 0o500) | ||
|
||
# Try to remove the directory - should raise a PermissionError or OSError | ||
with pytest.raises((PermissionError, OSError)): |
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 will not work if the tests are executed as root, root can do anything to a directory.
Why? This does not make any sense. This project is not a web application, there's no reason to use Selenium to test anything.
Honestly, there's no reason to test for most of these scenarios. It will never attempt to remove a socket or device, and if it did that is completely wrong. |
@dirkmueller the folder that I don't see a reason the change the current behavior of this function. |
Thank you for your effort, but we don't want a test for a scenario that we do not wish to support. |