{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/14133","labels_url":"https://api.github.com/repos/ansible/ansible/issues/14133/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/14133/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/14133/events","html_url":"https://github.com/ansible/ansible/issues/14133","id":128873818,"number":14133,"title":"Feature Idea: Provide import hooks for module/library code","user":{"login":"nrb","id":321387,"avatar_url":"https://avatars.githubusercontent.com/u/321387?v=3","gravatar_id":"","url":"https://api.github.com/users/nrb","html_url":"https://github.com/nrb","followers_url":"https://api.github.com/users/nrb/followers","following_url":"https://api.github.com/users/nrb/following{/other_user}","gists_url":"https://api.github.com/users/nrb/gists{/gist_id}","starred_url":"https://api.github.com/users/nrb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nrb/subscriptions","organizations_url":"https://api.github.com/users/nrb/orgs","repos_url":"https://api.github.com/users/nrb/repos","events_url":"https://api.github.com/users/nrb/events{/privacy}","received_events_url":"https://api.github.com/users/nrb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-01-26T16:41:12Z","updated_at":"2016-01-26T17:03:41Z","closed_at":null,"body":"Currently, when trying to write Python unit tests for Ansible module/library code, one must resort to doing their own import hacks, like described in https://nicolai86.eu/blog/posts/2014-02-05/testing-ansible-libraries/.\r\n\r\nTo avoid this, I wrote a new library, [`ansible_importer`](https://github.com/nrb/ansible_importer), that uses Python import hooks to find Ansible modules without peppering the file system with `__init__.py` files or having to rewrite the import code every time.\r\n\r\nIt may be useful for ansible itself to provide this functionality. I would propose that it be something like `ansible.imports.activate('abs/path/to/yaml/code')`."},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/175118141","html_url":"https://github.com/ansible/ansible/issues/14133#issuecomment-175118141","issue_url":"https://api.github.com/repos/ansible/ansible/issues/14133","id":175118141,"user":{"login":"bcoca","id":836171,"avatar_url":"https://avatars.githubusercontent.com/u/836171?v=3","gravatar_id":"","url":"https://api.github.com/users/bcoca","html_url":"https://github.com/bcoca","followers_url":"https://api.github.com/users/bcoca/followers","following_url":"https://api.github.com/users/bcoca/following{/other_user}","gists_url":"https://api.github.com/users/bcoca/gists{/gist_id}","starred_url":"https://api.github.com/users/bcoca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcoca/subscriptions","organizations_url":"https://api.github.com/users/bcoca/orgs","repos_url":"https://api.github.com/users/bcoca/repos","events_url":"https://api.github.com/users/bcoca/events{/privacy}","received_events_url":"https://api.github.com/users/bcoca/received_events","type":"User","site_admin":false},"created_at":"2016-01-26T17:03:41Z","updated_at":"2016-01-26T17:03:41Z","body":"no, but it produces the importable version of the script\n\n\n-- \nBrian Coca\n"}}