[Python] Why did the test fail on GitHub Actions with "TypeError: 'module' object is not...

Discussão em 'Python' iniciado por Stack, Junho 4, 2025.

  1. Stack

    Stack Membro Participativo

    My workflow file:

    on:
    workflow_call:
    pull_request:
    branches:
    - main
    workflow_dispatch:

    jobs:
    build:
    runs-on: lau-sr

    steps:
    - uses: actions/checkout@v4
    name: Checkout application repository
    with:
    repository: "mkpoz-group-ukraine/lau-provisioning"
    ref: dev
    - name: Install all devopslibs libraries
    run: |
    chmod +x ./install-libraries.bash
    ./install-libraries.bash
    shell: bash

    - name: Print current work directory
    run: pwd

    - name: Run tests
    run: |
    python -c "from devopslibs_alm_commons_utils.alm_commons_utils.lautest import test_lau_api_seesion; test_lau_api_seesion()"


    I got error

    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    TypeError: 'module' object is not callable
    Error: Process completed with exit code 1.


    My test file is quite big

    import pytest
    import asyncio
    import os
    from unittest.mock import Mock, patch, MagicMock, AsyncMock
    from enum import Enum
    from alm_commons_utils.mylau.lau_client import lauApiSession

    class TestlauApiSession:
    """Test suite for lauApiSession class"""

    @pytest.fixture
    def mock_dependencies(self):


    Which module object is not callable? I also check the workspaces but I am not sure how and if I should use the working directory. I am calling the function now

    Run python -c "from devopslibs_alm_commons_utils.alm_commons_utils.lautest.test_lau_api_seesion import mock_dependencies; mock_dependencies()"

    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    ImportError: cannot import name 'mock_dependencies' from 'devopslibs_alm_commons_utils.alm_commons_utils.lautest.test_lau_api_seesion' (/home/docker/actions-runner/_work/to-zdi-dev2/to-zdi-dev2/devopslibs_alm_commons_utils/alm_commons_utils/lautest/test_lau_api_seesion.py)


    It seems that something is wrong with my workspace.

    Continue reading...

Compartilhe esta Página