Error in running tests on local machine

Hello everyone,
I am trying to setup a clone of MSS on my local machine, I have installed all the dependencies but I get this error when I run the repo coverage test:

(mssdev) C:\Users\Gaurav Sharma\Desktop\OpenSource\mss>pytest --cov mslib
============================================== test session starts ==============================================
platform win32 -- Python 3.10.8, pytest-8.0.0, pluggy-1.4.0
PyQt5 5.15.9 -- Qt runtime 5.15.2 -- Qt compiled 5.15.2
rootdir: C:\Users\Gaurav Sharma\Desktop\OpenSource\mss
configfile: pytest.ini
plugins: anyio-4.2.0, cov-4.1.0, qt-4.4.0, reverse-1.7.0, timeout-2.2.0, xdist-3.5.0
timeout: 30.0s
timeout method: thread
timeout func_only: False
collected 439 items / 9 errors / 1 skipped

==================================================== ERRORS =====================================================
_______________________________ ERROR collecting tests/_test_msui/test_mscolab.py _______________________________
ImportError while importing test module 'C:\Users\Gaurav Sharma\Desktop\OpenSource\mss\tests\_test_msui\test_mscolab.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\miniforge\envs\mssdev\lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests\_test_msui\test_mscolab.py:42: in <module>
    from mslib.msui import msui
mslib\msui\msui.py:43: in <module>
    from mslib.msui.msui_mainwindow import MSUIMainWindow
mslib\msui\msui_mainwindow.py:41: in <module>
    from slugify import slugify
C:\miniforge\envs\mssdev\lib\site-packages\slugify.py:5: in <module>
    from array import _UnicodeTypeCode
E   ImportError: cannot import name '_UnicodeTypeCode' from 'array' (unknown location)
________________________ ERROR collecting tests/_test_msui/test_mscolab_admin_window.py _________________________ 
ImportError while importing test module 'C:\Users\Gaurav Sharma\Desktop\OpenSource\mss\tests\_test_msui\test_mscolab_admin_window.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\miniforge\envs\mssdev\lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests\_test_msui\test_mscolab_admin_window.py:33: in <module>
    from mslib.msui import msui
mslib\msui\msui.py:43: in <module>
    from mslib.msui.msui_mainwindow import MSUIMainWindow
mslib\msui\msui_mainwindow.py:41: in <module>
    from slugify import slugify
C:\miniforge\envs\mssdev\lib\site-packages\slugify.py:5: in <module>
    from array import _UnicodeTypeCode
E   ImportError: cannot import name '_UnicodeTypeCode' from 'array' (unknown location)
_______________________ ERROR collecting tests/_test_msui/test_mscolab_merge_waypoints.py _______________________ 
ImportError while importing test module 'C:\Users\Gaurav Sharma\Desktop\OpenSource\mss\tests\_test_msui\test_mscolab_merge_waypoints.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\miniforge\envs\mssdev\lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests\_test_msui\test_mscolab_merge_waypoints.py:38: in <module>
    from mslib.msui import msui
mslib\msui\msui.py:43: in <module>
    from mslib.msui.msui_mainwindow import MSUIMainWindow
mslib\msui\msui_mainwindow.py:41: in <module>
    from slugify import slugify
C:\miniforge\envs\mssdev\lib\site-packages\slugify.py:5: in <module>
    from array import _UnicodeTypeCode
E   ImportError: cannot import name '_UnicodeTypeCode' from 'array' (unknown location)
__________________________ ERROR collecting tests/_test_msui/test_mscolab_operation.py __________________________ 
ImportError while importing test module 'C:\Users\Gaurav Sharma\Desktop\OpenSource\mss\tests\_test_msui\test_mscolab_operation.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\miniforge\envs\mssdev\lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests\_test_msui\test_mscolab_operation.py:33: in <module>
    from mslib.msui import msui
mslib\msui\msui.py:43: in <module>
    from mslib.msui.msui_mainwindow import MSUIMainWindow
mslib\msui\msui_mainwindow.py:41: in <module>
    from slugify import slugify
C:\miniforge\envs\mssdev\lib\site-packages\slugify.py:5: in <module>
    from array import _UnicodeTypeCode
E   ImportError: cannot import name '_UnicodeTypeCode' from 'array' (unknown location)
______________________ ERROR collecting tests/_test_msui/test_mscolab_save_merge_points.py ______________________ 
ImportError while importing test module 'C:\Users\Gaurav Sharma\Desktop\OpenSource\mss\tests\_test_msui\test_mscolab_save_merge_points.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\miniforge\envs\mssdev\lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests\_test_msui\test_mscolab_save_merge_points.py:28: in <module>
    from tests._test_msui.test_mscolab_merge_waypoints import Test_Mscolab_Merge_Waypoints
tests\_test_msui\test_mscolab_merge_waypoints.py:38: in <module>
    from mslib.msui import msui
mslib\msui\msui.py:43: in <module>
    from mslib.msui.msui_mainwindow import MSUIMainWindow
mslib\msui\msui_mainwindow.py:41: in <module>
    from slugify import slugify
C:\miniforge\envs\mssdev\lib\site-packages\slugify.py:5: in <module>
    from array import _UnicodeTypeCode
E   ImportError: cannot import name '_UnicodeTypeCode' from 'array' (unknown location)
_______________________ ERROR collecting tests/_test_msui/test_mscolab_version_history.py _______________________ 
ImportError while importing test module 'C:\Users\Gaurav Sharma\Desktop\OpenSource\mss\tests\_test_msui\test_mscolab_version_history.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\miniforge\envs\mssdev\lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests\_test_msui\test_mscolab_version_history.py:33: in <module>
    from mslib.msui import msui
mslib\msui\msui.py:43: in <module>
    from mslib.msui.msui_mainwindow import MSUIMainWindow
mslib\msui\msui_mainwindow.py:41: in <module>
    from slugify import slugify
C:\miniforge\envs\mssdev\lib\site-packages\slugify.py:5: in <module>
    from array import _UnicodeTypeCode
E   ImportError: cannot import name '_UnicodeTypeCode' from 'array' (unknown location)
________________________________ ERROR collecting tests/_test_msui/test_msui.py _________________________________ 
ImportError while importing test module 'C:\Users\Gaurav Sharma\Desktop\OpenSource\mss\tests\_test_msui\test_msui.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\miniforge\envs\mssdev\lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests\_test_msui\test_msui.py:39: in <module>
    from mslib.msui import msui
mslib\msui\msui.py:43: in <module>
    from mslib.msui.msui_mainwindow import MSUIMainWindow
mslib\msui\msui_mainwindow.py:41: in <module>
    from slugify import slugify
C:\miniforge\envs\mssdev\lib\site-packages\slugify.py:5: in <module>
    from array import _UnicodeTypeCode
E   ImportError: cannot import name '_UnicodeTypeCode' from 'array' (unknown location)
___________________ ERROR collecting tests/_test_msui/test_multiple_flightpath_dockwidget.py ____________________ 
ImportError while importing test module 'C:\Users\Gaurav Sharma\Desktop\OpenSource\mss\tests\_test_msui\test_multiple_flightpath_dockwidget.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\miniforge\envs\mssdev\lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests\_test_msui\test_multiple_flightpath_dockwidget.py:29: in <module>
    from mslib.msui import msui
mslib\msui\msui.py:43: in <module>
    from mslib.msui.msui_mainwindow import MSUIMainWindow
mslib\msui\msui_mainwindow.py:41: in <module>
    from slugify import slugify
C:\miniforge\envs\mssdev\lib\site-packages\slugify.py:5: in <module>
    from array import _UnicodeTypeCode
E   ImportError: cannot import name '_UnicodeTypeCode' from 'array' (unknown location)
_______________________________ ERROR collecting tests/_test_msui/test_topview.py _______________________________ 
ImportError while importing test module 'C:\Users\Gaurav Sharma\Desktop\OpenSource\mss\tests\_test_msui\test_topview.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\miniforge\envs\mssdev\lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests\_test_msui\test_topview.py:33: in <module>
    import mslib.msui.topview as tv
mslib\msui\topview.py:45: in <module>
    from mslib.msui import multiple_flightpath_dockwidget as mf
mslib\msui\multiple_flightpath_dockwidget.py:33: in <module>
    import mslib.msui.msui_mainwindow as msui_mainwindow
mslib\msui\msui_mainwindow.py:41: in <module>
    from slugify import slugify
C:\miniforge\envs\mssdev\lib\site-packages\slugify.py:5: in <module>
    from array import _UnicodeTypeCode
E   ImportError: cannot import name '_UnicodeTypeCode' from 'array' (unknown location)

PS: Sorry for throwing all the code straight up.

This results in terminating the tests even before running:

ERROR tests/_test_msui/test_mscolab.py
ERROR tests/_test_msui/test_mscolab_admin_window.py
ERROR tests/_test_msui/test_mscolab_merge_waypoints.py
ERROR tests/_test_msui/test_mscolab_operation.py
ERROR tests/_test_msui/test_mscolab_save_merge_points.py
ERROR tests/_test_msui/test_mscolab_version_history.py
ERROR tests/_test_msui/test_msui.py
ERROR tests/_test_msui/test_multiple_flightpath_dockwidget.py
ERROR tests/_test_msui/test_topview.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 9 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

I would really appreciate some help in understanding why the modules cannot be imported.
Thanks in Advance.

Pytest may be hiding some details of the error, I am not sure on that.

What is the error when you try to import array from the python prompt of the version you are using?

Then check if array._UnicodeTypeCode exists.

Yes, array is imported just fine but the latter returns attribute error:

import array

if array._UnicodeTypeCode:
    print(0)
if array._UnicodeTypeCode:
AttributeError: module 'array' has no attribute '_UnicodeTypeCode'

Is it a necessary module that needs to be there?

The array module is part of python’s stdlib.
I cannot find a version of python that every had array._UnicodeTypeCode.
I wonder if the code expects to use an array module that is not the python one?

At this point I would ask the author of the code what is going on.

Okay, I’ll ask them.
Thanks for the response! Much appreciated.

The author just told me to use python 3.11 for develop branch. After installing the required version, I tried starting the app, the terminal shows :

Traceback (most recent call last):
  File "C:\Users\Gaurav Sharma\Desktop\OpenSource\mss\mslib\msui\msui.py", line 43, in <module>
    from mslib.msui.msui_mainwindow import MSUIMainWindow
  File "C:\Users\Gaurav Sharma\Desktop\OpenSource\mss\mslib\msui\msui_mainwindow.py", line 41, in <module>
    from slugify import slugify
  File "C:\miniforge\envs\mssdev\Lib\site-packages\slugify.py", line 5, in <module>
    from array import _UnicodeTypeCode
ImportError: cannot import name '_UnicodeTypeCode' from 'array' (unknown location)

I get the error is to not being able to import this _UnicodeTypeCode. Could there be a possible solution to this?

Ask the author to fix their code. _UnicodeTypeCode was at best an undocumented internal attribute that got removed, if it was ever part of the stdlib. It seems to only be part of typeshed and never available at runtime.

1 Like

Which version of python-slugify is this?

Have a look if you can update to 8.0.4, e…g. mamba update python-slugify
https://anaconda.org/conda-forge/python-slugify/

We can pin python-slugify to a version without that bug.

1 Like