Skip to content

Confusing error when I have errors in source code #257

@sporto

Description

@sporto

I had a file with:

import functools
from typings import List

...

Note that typings is an invalid import. It should be typing

Trying to run green I got:

❯ poetry run green extract/lib/test/test_rules.py
E

Error in .unittest.loader
TypeError: Test loader returned an un-runnable object.  Is "unittest.loader" importable from your current location?  Maybe you forgot an __init__.py in your directory?  Unrunnable object looks like: None of type <class 'NoneType'> with dir ['__bool__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']

Ran 1 test in 0.024s using 8 processes

FAILED (errors=1)

The error doesn't give a hint of what the issue is.

Then I tried pytest:

❯ poetry run pytest extract/lib/test/test_rules.py
...

========================================================================================================================================== ERRORS ==========================================================================================================================================
_____________________________________________________________________________________________________________________ ERROR collecting extract/lib/test/test_rules.py ______________________________________________________________________________________________________________________
ImportError while importing test module '/home/sebastian/Source/staxio/cost-spike-1/extract_py/extract/lib/test/test_rules.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/linuxbrew/.linuxbrew/opt/python@3.9/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
extract/lib/test/test_rules.py:1: in <module>
    import extract.lib.rules as rules
extract/lib/rules.py:2: in <module>
    from typings import List
E   ModuleNotFoundError: No module named 'typings'
================================================================================================================================= short test summary info ==================================================================================================================================
ERROR extract/lib/test/test_rules.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
===================================================================================================================================== 1 error in 0.07s =====================================================================================================================================

Note ModuleNotFoundError: No module named 'typings'

Would be great if green could show the error.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions