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

Tests fail with "ImportError: cannot import name 'json_available' from 'flask'" #15

Closed
sajith opened this issue Aug 8, 2022 · 2 comments
Assignees
Labels

Comments

@sajith
Copy link
Member

sajith commented Aug 8, 2022

I am trying to have a GitHub Actions setup going for this repository (current progress here), and there are errors when running tests with Python 3.9:

$ python -m tox
  shell: /usr/bin/bash -e {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.9.13/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.13/x64/lib

[...]

ERROR: Failure: ImportError (cannot import name 'json_available' from 'flask' (/home/runner/work/sdx-lc/sdx-lc/.tox/py3/lib/python3.9/site-packages/flask/__init__.py))
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/sdx-lc/sdx-lc/.tox/py3/lib/python3.9/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/home/runner/work/sdx-lc/sdx-lc/.tox/py3/lib/python3.9/site-packages/nose/loader.py", line 417, in loadTestsFromName
    module = self.importer.importFromPath(
  File "/home/runner/work/sdx-lc/sdx-lc/.tox/py3/lib/python3.9/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/runner/work/sdx-lc/sdx-lc/.tox/py3/lib/python3.9/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/opt/hostedtoolcache/Python/3.9.13/x64/lib/python3.9/imp.py", line 244, in load_module
    return load_package(name, filename)
  File "/opt/hostedtoolcache/Python/3.9.13/x64/lib/python3.9/imp.py", line 216, in load_package
    return _load(spec)
  File "<frozen importlib._bootstrap>", line 711, in _load
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/runner/work/sdx-lc/sdx-lc/swagger_server/test/__init__.py", line 4, in <module>
    from flask_testing import TestCase
  File "/home/runner/work/sdx-lc/sdx-lc/.tox/py3/lib/python3.9/site-packages/flask_testing/__init__.py", line 13, in <module>
    from .utils import TestCase, LiveServerTestCase
  File "/home/runner/work/sdx-lc/sdx-lc/.tox/py3/lib/python3.9/site-packages/flask_testing/utils.py", line 38, in <module>
    from flask import json_available, templating, template_rendered
ImportError: cannot import name 'json_available' from 'flask' (/home/runner/work/sdx-lc/sdx-lc/.tox/py3/lib/python3.9/site-packages/flask/__init__.py)

----------------------------------------------------------------------
Ran 1 test in 0.581s

FAILED (errors=1)
ERROR: InvocationError for command /home/runner/work/sdx-lc/sdx-lc/.tox/py3/bin/nosetests (exited with code 1)
@sajith sajith self-assigned this Aug 8, 2022
@sajith sajith changed the title Tests fail with Python 3.9 Tests fail with "ImportError: cannot import name 'json_available' from 'flask'" Aug 9, 2022
@sajith
Copy link
Member Author

sajith commented Aug 9, 2022

This error happens with all Python 3.x versions that I have tested with, except Python 3.10. (There's a different, unrelated error with Python 3.10, and that of course is a different discussion.)

This error happens because Flask 2.0.0 has dropped flask.json_available flag, and flask-testing also have subsequently removed it, here: jarus/flask-testing#136.

Upgrading flask-testing to 0.8.1 should handle this. I wiill make that PR once we have CI running.

@sajith
Copy link
Member Author

sajith commented Aug 11, 2022

This particular error is addressed in PR #17.

@sajith sajith closed this as completed Aug 11, 2022
@sajith sajith added the ci/cd label Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

1 participant