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

Confusing error when I have errors in source code #257

Open
sporto opened this issue Apr 14, 2022 · 4 comments
Open

Confusing error when I have errors in source code #257

sporto opened this issue Apr 14, 2022 · 4 comments

Comments

@sporto
Copy link

sporto commented Apr 14, 2022

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

@CleanCut
Copy link
Owner

Can you please provide:

  • The output of green -V
  • The name and version of your Operating System?

@sporto
Copy link
Author

sporto commented Apr 15, 2022

green -V
Green 3.4.1, Coverage 6.3.2, Python 3.9.12

I tried this in PopOS (Ubuntu 21.10) and MacOS (Intel mac) with the same result.

This only happens when you try to run one test. e.g. green test/test_x.py
If I try to run the whole test suite it shows the proper error.

@CleanCut
Copy link
Owner

This only happens when you try to run one test. e.g. green test/test_x.py
If I try to run the whole test suite it shows the proper error.

Ah! That's extremely helpful information, thanks!

@CleanCut
Copy link
Owner

FYI, I spent a couple hours looking into this, and it's quite tricky to fix without breaking other features. I plan to take another look at it sometime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants