Skip to content

Got this error while doing hatch test via hatch shell #1364

Closed

Description

@DSCmatter

Steps to Reproduce:

  1. cd packages/markitdown
  2. hatch shell
  3. hatch test
\markitdown\packages\markitdown> hatch test 
==================================================================== test session starts ====================================================================
platform win32 -- Python 3.11.4, pytest-8.4.1, pluggy-1.6.0
rootdir: D:\Coding\markitdown\packages\markitdown
configfile: pyproject.toml
plugins: anyio-4.9.0, mock-3.14.1, rerunfailures-14.0, xdist-3.8.0
collected 50 items / 3 errors                                                                                                                                

========================================================================== ERRORS ===========================================================================
__________________________________________________________ ERROR collecting tests/test_cli_misc.py __________________________________________________________
ImportError while importing test module 'D:\Coding\markitdown\packages\markitdown\tests\test_cli_misc.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests\test_cli_misc.py:3: in <module>
    from markitdown import __version__
E   ModuleNotFoundError: No module named 'markitdown'
________________________________________________________ ERROR collecting tests/test_module_misc.py _________________________________________________________ 
ImportError while importing test module 'D:\Coding\markitdown\packages\markitdown\tests\test_module_misc.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests\test_module_misc.py:8: in <module>
    from markitdown._uri_utils import parse_data_uri, file_uri_to_path
E   ModuleNotFoundError: No module named 'markitdown'
_______________________________________________________ ERROR collecting tests/test_module_vectors.py _______________________________________________________ 
ImportError while importing test module 'D:\Coding\markitdown\packages\markitdown\tests\test_module_vectors.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests\test_module_vectors.py:14: in <module>
    from markitdown import (
E   ModuleNotFoundError: No module named 'markitdown'
================================================================== short test summary info ================================================================== 
ERROR tests/test_cli_misc.py
ERROR tests/test_module_misc.py
ERROR tests/test_module_vectors.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
===================================================================== 3 errors in 0.34s ===================================================================== 

Activity

  1. yossefelnggar commented on Jul 19, 2025

    @yossefelnggar

    Hey, I ran into the same issue and found a fix.

    The problem is that when running hatch test, pytest can't locate the markitdown module because it's under the src/ directory. To fix this, just make sure pytest knows where to look by adding this to your pyproject.toml:

    toml

    [tool.pytest.ini_options]
    pythonpath = "src"
    You can place it around line 77 or just under any existing [tool...] section.

    Once added, rerun your tests with:

    bash

    hatch shell
    hatch test
    This should fix the ModuleNotFoundError errors during test collection.

    Let me know if it works for you!

  2. DSCmatter commented on Jul 19, 2025

    @DSCmatter
    Author

    LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions