skip 000 permission tests for root user by burnout-projects · Pull Request #561 · theskumar/python-dotenv
What
This pull request modifies the unit tests to skip two specific tests if the underlying user is "root".
Why
Two of the unit tests fail (false negatives) if executed as the "root" user on Linux. This change is necessary because the tests involve changing file permissions to 000 and verifying if the user can access the file. Since the root user has unrestricted access to the entire file system, these tests are not applicable to the root user.
Details
-
Tests Affected:
test_set_key_permission_error()test_set_key_unauthorized_file()
-
Implementation: The tests now include a condition to check if the underlying user is "root". If the user is root, the tests are skipped using the
pytest.skipfunction.
Impact
- Positive: Ensures that the test suite runs correctly and avoids false negatives when executed by the root user.
- Negative: None identified.
Testing
- The changes have been tested in both root and non-root environments to verify that the tests are skipped for the root user and executed correctly for non-root users.