Skip to content
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(test_scanner.py): Add test for unopenable file condition #4834

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JigyasuRajput
Copy link
Contributor

Description

Fixes #762

  • Introduces a new test to cover scenarios where a file exists but cannot be opened (e.g., due to permission issues).
  • Complements the existing test for non-existent files, enhancing overall error handling coverage.

Changes

  • New Test: test_unopenable_file
    • Creates a temporary file and forces an OSError (simulating a permission error) using unittest.mock.patch.
    • Asserts that the scan_file function handles the error by raising a StopIteration.
  • Existing Test: test_cannot_open_file
    • Continues to validate behavior when a file does not exist and ensures proper logging of an "Invalid file" message.

Testing

  • Purpose:
    • Ensures that the scanner behaves correctly in both scenarios:
      • Non-existent file.
      • File exists but is unopenable due to permissions.
  • Expected Outcome:
    • Both tests should raise a StopIteration, confirming that the error handling in scanner.py is robust.

Additional Context

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.

Add test for "unopenable file" condition in scanner.py
1 participant