HENNGE / arsenic

Async WebDriver implementation for asyncio and asyncio-compatible frameworks
Other
349 stars 52 forks source link

Unable to run tests because of broken dependency #153

Closed mjarosie closed 1 year ago

mjarosie commented 1 year ago

When trying to run the tests locally, the command fails with the following error:

ImportError while loading conftest '/home/mjarosie/source/mjarosie/arsenic/tests/conftest.py'.
tests/conftest.py:13: in <module>
    from .app import build_app
tests/app.py:4: in <module>
    from jinja2 import FileSystemLoader, Environment
../../../.cache/pypoetry/virtualenvs/arsenic-AKF9VmY4-py3.10/lib/python3.10/site-packages/jinja2/__init__.py:12: in <module>
    from .environment import Environment
../../../.cache/pypoetry/virtualenvs/arsenic-AKF9VmY4-py3.10/lib/python3.10/site-packages/jinja2/environment.py:25: in <module>
    from .defaults import BLOCK_END_STRING
../../../.cache/pypoetry/virtualenvs/arsenic-AKF9VmY4-py3.10/lib/python3.10/site-packages/jinja2/defaults.py:3: in <module>
    from .filters import FILTERS as DEFAULT_FILTERS  # noqa: F401
../../../.cache/pypoetry/virtualenvs/arsenic-AKF9VmY4-py3.10/lib/python3.10/site-packages/jinja2/filters.py:13: in <module>
    from markupsafe import soft_unicode
E   ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/home/mjarosie/.cache/pypoetry/virtualenvs/arsenic-AKF9VmY4-py3.10/lib/python3.10/site-packages/markupsafe/__init__.py)

It's caused by using an old version of Jinja2 with its broken dependency (markupsafe): https://github.com/pallets/markupsafe/issues/282

Steps to reproduce:

poetry install
poetry run pytest --verbose tests

One solution would be to pin markupsafe dependency to 2.0.1 as suggested in this SO answer. Another solution would be to update Jinja2 dependency, which seems safe as it's a dev-dependency anyway.

EDIT:

It turns out the CI check is failing because of yet another outdated dependency. Invoking black causes the following error:

ImportError: cannot import name '_unicodefun' from 'click' 

More details about the cause: https://github.com/psf/black/issues/2964

EDIT:

After updating Jinja2 to its latest version (^3.1.2) it turns out sphinx-build isn't happy because:

ImportError: cannot import name 'environmentfilter' from 'jinja2' 

Pinning to Jinja2<3.1 apparently should fix it.

EDIT:

Pinning to Jinja2<3.1 did fix the issue and the build is green now. I've tried upgrading sphinx version instead which also results in a green build. As a side effect https://arsenic.readthedocs.io will get a refreshed look, such as a navigation bar which I was going to mention in another GitHub issue anyway.

Old look

image

New look

image