Skip to content

Python tests cannot collect — numpy is undeclared and the install step swallows the error #40

Description

@srpatcha

The Python test suite cannot collect. Found within a minute of restoring CI
(#39), having been invisible since May.

tests/unit/test_unit_core.py:10: in <module>
    import numpy as np
E   ModuleNotFoundError: No module named 'numpy'

ERROR tests/unit/test_unit_core.py
Interrupted: 1 error during collection
1 error in 0.24s
exit code 2

Two separate problems

numpy is not declared anywhere. No requirements.txt, and nothing in
pyproject.toml or setup.py. The suite depends on it and says so nowhere, so
it works on any machine that happens to have it and nowhere else.

The workflow hides that. ci.yml:44-45

pip install pytest pytest-cov
pip install -r requirements.txt 2>/dev/null || true

requirements.txt does not exist. 2>/dev/null || true turns "there is nothing
to install" into a silent success, so the step is green and the failure surfaces
later as a confusing import error in pytest rather than as "your dependency file
is missing".

That line is doing real harm: it would swallow a genuine pip install failure —
a broken index, a version conflict, a package that no longer resolves — with the
same silence.

Fix

  1. Declare the dependency. A requirements.txt with numpy (pinned to a major
    at least), or add it to pyproject.toml if this package has one.

  2. Stop suppressing the install step. If requirements.txt is meant to be
    optional, test for it explicitly rather than discarding all errors:

    - name: Install dependencies
      run: |
        pip install pytest pytest-cov
        if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

    The difference matters: the current form is also green when pip fails for a
    reason nobody wants to ignore.

Context

This is the first thing the restored CI found, which is the argument for
restoring it. C/C++ Tests passes; only Python is red. Three months of changes
landed here with no gate, and the count of what else is broken is unknown until
this one is cleared and collection can proceed.

The same trigger bug is fixed in five sibling repositories — eNI#30, eIPC#31,
eDB#70, eBrowser#20, eOffice#40 — and each is likely to surface its own first
failure the same way.

Activity

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