Skip to content

Question: Module discovery for a new module #436

Closed
@bearrito

Description

@bearrito

Hello,

I'm working on a new module for https://nats.io/
How does module discovery work?

For instance VSCode test discovery is unhappy with the new module

_______________ ERROR collecting modules/nats/tests/test_nats.py _______________
ImportError while importing test module '/workspaces/testcontainers-python/modules/nats/tests/test_nats.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
modules/nats/tests/test_nats.py:1: in <module>
    from testcontainers.nats import NatsContainer
E   ModuleNotFoundError: No module named 'testcontainers.nats'
=========================== short test summary info ============================
ERROR modules/nats/tests/test_nats.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
===================== 44 tests collected, 1 error in 0.97s =====================

Thinking this is a VScode issue I tried via just poetry

(testcontainers-_53phrdA-py3.11) vscode ➜ /workspaces/testcontainers-python (feature/nats) $ poetry run pytest -v --cov=testcontainers.$* modules/nats/tests
===================================================== test session starts ======================================================
platform linux -- Python 3.11.8, pytest-7.4.3, pluggy-1.4.0 -- /home/vscode/.cache/pypoetry/virtualenvs/testcontainers-_53phrdA-py3.11/bin/python
cachedir: .pytest_cache
rootdir: /workspaces/testcontainers-python
configfile: pyproject.toml
plugins: cov-4.1.0, anyio-4.3.0
collected 0 items / 1 error                                                                                                    
/home/vscode/.cache/pypoetry/virtualenvs/testcontainers-_53phrdA-py3.11/lib/python3.11/site-packages/coverage/inorout.py:503: CoverageWarning: Module testcontainers. was never imported. (module-not-imported)
  self.warn(f"Module {pkg} was never imported.", slug="module-not-imported")
/home/vscode/.cache/pypoetry/virtualenvs/testcontainers-_53phrdA-py3.11/lib/python3.11/site-packages/coverage/control.py:885: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
WARNING: Failed to generate report: No data to report.

/home/vscode/.cache/pypoetry/virtualenvs/testcontainers-_53phrdA-py3.11/lib/python3.11/site-packages/pytest_cov/plugin.py:312: CovReportWarning: Failed to generate report: No data to report.

  warnings.warn(CovReportWarning(message))

============================================================ ERRORS ============================================================
_______________________________________ ERROR collecting modules/nats/tests/test_nats.py _______________________________________
ImportError while importing test module '/workspaces/testcontainers-python/modules/nats/tests/test_nats.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
modules/nats/tests/test_nats.py:1: in <module>
    from testcontainers.nats import NatsContainer
E   ModuleNotFoundError: No module named 'testcontainers.nats'

I think my directory structure is correct

nats

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions