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

ImportWarning: can't resolve package from __spec__ or __package__ #4423

Closed
Callek opened this issue Nov 19, 2018 · 5 comments
Closed

ImportWarning: can't resolve package from __spec__ or __package__ #4423

Callek opened this issue Nov 19, 2018 · 5 comments
Labels
topic: collection related to the collection phase topic: rewrite related to the assertion rewrite mechanism type: bug problem that needs to be addressed

Comments

@Callek
Copy link

Callek commented Nov 19, 2018

Related to #3061

I'm hitting this in @mozilla-releng/addonscript with pytest 4.0 on travis (locally reproduced back to pytest 3.7.3) --

Travis Log: https://travis-ci.org/mozilla-releng/addonscript/builds/457101239

Local pytest extensions

  • pytest-asyncio
  • pytest-cov
  • pytest-mock

I'm also getting no traceback at all..

====================================================== warnings summary ======================================================
.tox/py36/lib/python3.6/importlib/_bootstrap.py:219
  /home/callek/mozilla/git/addonscript/.tox/py36/lib/python3.6/importlib/_bootstrap.py:219: ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
    return f(*args, **kwds)

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=========================================== 64 passed, 1 warnings in 0.61 seconds ============================================
py36 runtests: commands[3] | coverage html
py36 runtests: commands[4] | flake8
@Callek
Copy link
Author

Callek commented Nov 19, 2018

I should note that I've been using py.test -Wd ... as my invocation for a quite a while and this is the first I've seen it (the upgrade of pytest)

@RonnyPfannschmidt RonnyPfannschmidt added type: bug problem that needs to be addressed topic: collection related to the collection phase topic: rewrite related to the assertion rewrite mechanism labels Nov 19, 2018
@RonnyPfannschmidt
Copy link
Member

thanks for the report - i vaguely suspect we need to do some extra work to do the correct thing in the assertion rewriter

@asottile
Copy link
Member

Here's the stacktrace:

$ pytest --maxfail 1 -Werror
============================= test session starts ==============================
platform linux -- Python 3.6.6, pytest-4.0.0, py-1.7.0, pluggy-0.8.0 -- /tmp/addonscript/venv/bin/python3
cachedir: .pytest_cache
rootdir: /tmp/addonscript, inifile: tox.ini
plugins: mock-1.10.0, asyncio-0.9.0
collecting ... 
==================================== ERRORS ====================================
________________ ERROR collecting addonscript/test/test_api.py _________________
addonscript/test/test_api.py:4: in <module>
    import aiohttp
venv/lib/python3.6/site-packages/aiohttp/__init__.py:5: in <module>
    from . import hdrs  # noqa
venv/lib/python3.6/site-packages/aiohttp/hdrs.py:6: in <module>
    from multidict import istr
venv/lib/python3.6/site-packages/multidict/__init__.py:23: in <module>
    from ._multidict import (MultiDictProxy,
multidict/_multidict.pyx:9: in init multidict._multidict
    ???
E   ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
=========================== 1 error in 0.04 seconds ============================

Running this outside of `pytest:

$ python -Wonce -c 'import multidict'
/tmp/addonscript/venv/lib/python3.6/site.py:165: DeprecationWarning: 'U' mode is deprecated
  f = open(fullname, "rU")
_frozen_importlib:219: ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__

This isn't an issue with pytest but with multidict

@asottile
Copy link
Member

I've taken some time and figured out what multidict needs to do to fix this: aio-libs/multidict#304

closing this! Thanks for the issue, this was fun 🎉

@asottile
Copy link
Member

@Callek btw, if you upgrade to multidict==4.5.0 that error is fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: collection related to the collection phase topic: rewrite related to the assertion rewrite mechanism type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

3 participants