ansible / ansible-container

DEPRECATED -- Ansible Container was a tool to build Docker images and orchestrate containers using only Ansible playbooks.
GNU Lesser General Public License v3.0
2.19k stars 392 forks source link

ImportError while importing test module #957

Closed kbabioch closed 5 years ago

kbabioch commented 6 years ago
ISSUE TYPE
SUMMARY

Running the test suite with PYTHONPATH set to . fails with multiple ModuleNotFoundError. This is an issue when packaging the software, since I'm using setuptools and do not want to install it using pip -e, etc.

STEPS TO REPRODUCE

1.) Clone the repository:

$ git clone git@github.com:ansible/ansible-container.git

2.) Try to run the test suite:

$ PYTHONPATH=. pytest
EXPECTED RESULTS

Test suite should successfully run

ACTUAL RESULTS

Several import errors:

$ PYTHONPATH=. pytest
============================================================================ test session starts ============================================================================
platform linux -- Python 3.6.6, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
rootdir: /home/kbabioch/PKGBUILD/ansible-container-git/ansible-container, inifile:
plugins: cov-2.5.1
collected 1 item / 2 errors                                                                                                                                                 

================================================================================== ERRORS ===================================================================================
____________________________________________________________ ERROR collecting test/unit/container/test_config.py ____________________________________________________________
ImportError while importing test module '/home/kbabioch/PKGBUILD/ansible-container-git/ansible-container/test/unit/container/test_config.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
test/unit/container/test_config.py:9: in <module>
    from container.config import AnsibleContainerConfig
container/config.py:21: in <module>
    import jsonschema
E   ModuleNotFoundError: No module named 'jsonschema'
_________________________________________________________ ERROR collecting test/unit/container/docker/test_utils.py _________________________________________________________
ImportError while importing test module '/home/kbabioch/PKGBUILD/ansible-container-git/ansible-container/test/unit/container/docker/test_utils.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
test/unit/container/docker/test_utils.py:8: in <module>
    from container.docker.utils import which_docker, config_to_compose
E   ModuleNotFoundError: No module named 'container.docker.utils'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================================================== 2 error in 0.54 seconds ==========================================================================
FAIL: 2
Voronenko commented 5 years ago

Take a look on https://github.com/ansible/ansible-container/blob/develop/.travis.yml#L24

There are some dependencies that need to be installed in advance in your development environment