lipoja / URLExtract

URLExtract is python class for collecting (extracting) URLs from given text based on locating TLD.
MIT License
244 stars 61 forks source link

Can't run test code: ModuleNotFoundError: No module named 'platformdirs' #107

Closed za closed 2 years ago

za commented 2 years ago

Refer to the documentation, I can't run the test code. Am I missing something?

(.env) ➜  URLExtract git:(master) ✗ tox                                                                                                                                      
GLOB sdist-make: /home/za/git/URLExtract/setup.py                                                                                                                            
py-nocache inst-nodeps: /home/za/git/URLExtract/.tox/.tmp/package/1/urlextract-1.4.0.zip                                                                                     
py-nocache installed: appdirs==1.4.4,attrs==21.2.0,bump2version==1.0.1,dnspython==2.1.0,filelock==3.3.1,idna==3.3,iniconfig==1.1.1,packaging==21.0,pluggy==1.0.0,py==1.10.0,p
yparsing==3.0.1,pytest==6.2.5,toml==0.10.2,uritools==3.0.2,urlextract @ file:///home/za/git/URLExtract/.tox/.tmp/package/1/urlextract-1.4.0.zip
py-nocache run-test-pre: PYTHONHASHSEED='2394630188'
py-nocache run-test: commands[0] | pytest --ignore setup.py
============================================================================ test session starts ============================================================================
platform linux -- Python 3.8.10, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
cachedir: .tox/py-nocache/.pytest_cache
rootdir: /home/za/git/URLExtract
collected 0 items / 1 error                                                                                                                                                 

================================================================================== ERRORS ===================================================================================
_______________________________________________________________________ ERROR collecting test session _______________________________________________________________________
/usr/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1014: in _gcd_import
    ???
<frozen importlib._bootstrap>:991: in _find_and_load
    ???
<frozen importlib._bootstrap>:975: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:671: in _load_unlocked
    ???
.tox/py-nocache/lib/python3.8/site-packages/_pytest/assertion/rewrite.py:170: in exec_module
    exec(co, module.__dict__)
tests/unit/conftest.py:9: in <module>
    from urlextract import URLExtract
.tox/py-nocache/lib/python3.8/site-packages/urlextract/__init__.py:1: in <module>
    from .urlextract_core import URLExtract, _urlextract_cli, __version__
.tox/py-nocache/lib/python3.8/site-packages/urlextract/urlextract_core.py:23: in <module>
    from urlextract.cachefile import CacheFile, CacheFileError
.tox/py-nocache/lib/python3.8/site-packages/urlextract/cachefile.py:20: in <module>
    from platformdirs import user_cache_dir 
E   ModuleNotFoundError: No module named 'platformdirs'
========================================================================== short test summary info ==========================================================================
ERROR  - ModuleNotFoundError: No module named 'platformdirs'

I can import it though via Python shell:

(.env) ➜  URLExtract git:(master) which python
/home/za/git/URLExtract/.env/bin/python
(.env) ➜  URLExtract git:(master) python
Python 3.8.10 (default, Sep 28 2021, 16:10:42) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import platformdirs
za commented 2 years ago

It's solved now. I need to remove .tox folder.

(.env) ➜  URLExtract git:(master) rm -rf .tox         
(.env) ➜  URLExtract git:(master) tox
GLOB sdist-make: /home/za/git/URLExtract/setup.py
py-nocache create: /home/za/git/URLExtract/.tox/py-nocache
py-nocache installdeps: ., -rrequirements.txt
py-nocache inst: /home/za/git/URLExtract/.tox/.tmp/package/1/urlextract-1.4.0.zip
py-nocache installed: attrs==21.2.0,bump2version==1.0.1,dnspython==2.1.0,filelock==3.3.2,idna==3.3,iniconfig==1.1.1,packaging==21.2,platformdirs==2.4.0,pluggy==1.0.0,py==1.1
1.0,pyparsing==2.4.7,pytest==6.2.5,toml==0.10.2,uritools==3.0.2,urlextract @ file:///home/za/git/URLExtract/.tox/.tmp/package/1/urlextract-1.4.0.zip
py-nocache run-test-pre: PYTHONHASHSEED='212727625'
py-nocache run-test: commands[0] | pytest --ignore setup.py
============================================================================ test session starts ============================================================================
platform linux -- Python 3.8.10, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
cachedir: .tox/py-nocache/.pytest_cache
rootdir: /home/za/git/URLExtract
collected 110 items                                                                                                                                                         

tests/unit/test_dns.py ........                                                                                                                                       [  7%]
tests/unit/test_enclosure.py .....................................                                                                                                    [ 40%]
lipoja commented 2 years ago

I am glad to hear that you have resolved it. Maybe running tox -r would help as well.

Thanks!