Skip to content

Bug: test_main.py imports fail silently when is_one_one module is missing __init__.py #83

@anshul23102

Description

@anshul23102

Description

The test suite fails to properly detect missing or malformed module initialization files. When is_one_one/__init__.py is missing or empty, the test file imports fail, but the error is caught by an overly broad exception handler, resulting in cryptic test failures instead of clear import errors.

This makes debugging difficult for new contributors who fork the repo and run tests.

Steps to Reproduce

  1. Clone the repository
  2. Remove or rename is_one_one/__init__.py
  3. Run pytest: pytest test_main.py
  4. Observe the error message

Expected: Clear ImportError or ModuleNotFoundError stating that is_one_one module cannot be found
Actual: Cryptic error message like 'unexpected keyword argument' or 'NoneType has no attribute...'

Environment Information

  • Python: 3.8+
  • pytest: 7.x+
  • OS: macOS / Linux / Windows

Expected Behavior

The test should fail immediately with a clear message: 'ModuleNotFoundError: No module named is_one_one' or similar

Actual Behavior

The test fails with an unhelpful error message because the import exception is caught and suppressed

Additional Context

Root cause: The test file likely has a bare except: clause or except Exception: that catches the import error along with other exceptions.

Proposed fix: Replace broad exception handlers with specific ones:

# BAD
try:
    from is_one_one import *
except:  # catches everything including import errors
    pass

# GOOD
try:
    from is_one_one import *
except (ImportError, ModuleNotFoundError) as e:
    raise ImportError(f"Failed to import is_one_one: {e}") from e

Severity: Low - affects development workflow, not production code.

Expected GSSoC points: Level 1 (beginner test infrastructure fix)

Suggested Labels

bug, level:beginner, gssoc, testing

Checklist

  • Searched existing issues, not a duplicate
  • Read CONTRIBUTING.md guidelines
  • Read README and understand project scope
  • Provided clear reproduction steps
  • Provided environment information
  • Described expected vs. actual clearly
  • No AI/Claude mentions
  • No em dashes or double hyphens
  • Repository verified as GSSoC

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions