glato/emerge

Failed tests with ImportError: cannot import name 'Iterable' from 'collections'

krotoff opened this issue · 6 comments

Failed tests
I have failed tests on step 5.

Describe your environment

  • MacOS 12.0.1 Monterrey
  • Python 3.10.2
  • Google Chrome 94.0.4606.81
  • Branch dev/1.1.0

To Reproduce

  1. $git clone https://github.com/glato/emerge.git
  2. $brew install graphviz
  3. $cd emerge
  4. $pip3 install virtualenv
  5. $virtualenv -p python3 venv
  6. $source venv/bin/activate
  7. $pip install -r requirements.txt
  8. $python emerge/tests/run_tests.py

Expected behavior
Successful tests

Reality

Traceback (most recent call last):
  File "/Users/akrotov/Downloads/emerge/emerge/tests/run_tests.py", line 9, in <module>
    from interrogate import coverage
  File "/Users/akrotov/Downloads/emerge/venv/lib/python3.10/site-packages/interrogate/coverage.py", line 10, in <module>
    import tabulate
  File "/Users/akrotov/Downloads/emerge/venv/lib/python3.10/site-packages/tabulate.py", line 16, in <module>
    from collections import Iterable
ImportError: cannot import name 'Iterable' from 'collections' (/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/collections/__init__.py)
glato commented

Hi @krotoff 👋, thanks for the feedback. You seem to be right. As a matter of fact, I was able to solve this first issue by simply upgrading tabulate:

pip install tabulate==0.8.9 -U

since there seems to be a bug related to python 3.10, but unfortunately another issue came up. It seems there is a problem with the current import module structure when executing the unit tests from the command line. The interesting part is, this seems to work pretty fine by using test discovery and execution within vscode:

CleanShot 2022-02-15 at 21 24 03@2x

Will have to check this in detail in the following days. Maybe I need to implement unit tests for the unit tests 👀.

Hello, @glato!

Recursion as it is :)

glato commented

@krotoff Had the time to figure out, how to manually get the tests running from the command line again. While in the project root directory, simply do a

python -m unittest discover -v -s ./emerge -p "test_*.py"

This should hopefully start and run all present tests and give an output that ends similar to

Ran 21 tests in 1.046s

OK

I will update requirements.txt and setup.py to match tabulate 0.8.9, update the README and adjust run_tests.py in the next release. Will make a small README update before the next release that mentions the command line version.

Thanks again for the hint.

@glato glad to hear it and to help :)

glato commented

@krotoff Updated tabulate, unit tests and README in the current release 1.2.0 so that it should be working fine again.

@glato thank you! Tests are working now :)