Skip to content
Snippets Groups Projects
  • Will Szumski's avatar
    4fcbdd77
    Stop mocking ansible modules globally · 4fcbdd77
    Will Szumski authored
    This causes non-local side effects that are hard to track down. E.g:
    
    --- import errors ---
    Failed to import test module: tests.test_merge_yaml
    Traceback (most recent call last):
      File "/home/will/.pyenv/versions/3.7.7/lib/python3.7/unittest/loader.py", line 436, in _find_test_path
        module = self._get_module_from_name(name)
      File "/home/will/.pyenv/versions/3.7.7/lib/python3.7/unittest/loader.py", line 377, in _get_module_from_name
        __import__(name)
      File "/home/will/code/kolla-ansible/tests/test_merge_yaml.py", line 19, in <module>
        from ansible.errors import AnsibleModuleError
    ModuleNotFoundError: No module named 'ansible.errors'; 'ansible' is not a package
    
    This `'ansible' is not a package` message occurs because ansible is a Mock.
    
    Depends-On: https://review.opendev.org/#/c/726768/
    Change-Id: Iddbdd3d855daadbf12536cc990559e6b8e123051
    4fcbdd77
    History
    Stop mocking ansible modules globally
    Will Szumski authored
    This causes non-local side effects that are hard to track down. E.g:
    
    --- import errors ---
    Failed to import test module: tests.test_merge_yaml
    Traceback (most recent call last):
      File "/home/will/.pyenv/versions/3.7.7/lib/python3.7/unittest/loader.py", line 436, in _find_test_path
        module = self._get_module_from_name(name)
      File "/home/will/.pyenv/versions/3.7.7/lib/python3.7/unittest/loader.py", line 377, in _get_module_from_name
        __import__(name)
      File "/home/will/code/kolla-ansible/tests/test_merge_yaml.py", line 19, in <module>
        from ansible.errors import AnsibleModuleError
    ModuleNotFoundError: No module named 'ansible.errors'; 'ansible' is not a package
    
    This `'ansible' is not a package` message occurs because ansible is a Mock.
    
    Depends-On: https://review.opendev.org/#/c/726768/
    Change-Id: Iddbdd3d855daadbf12536cc990559e6b8e123051