Serge,

Thanks for the info, it led me in the right direction. I had reviewed both 
documents, but missed the statement about running a pytest against a single 
test case.

I finally got the test case to work using the  pytest -r a --cov=. 
--cov-report=html --fulltrace --color yes <path to test> command referenced 
with the following caveats:

   1. The --cov parameters resulted in a failure. It looks like I'll need 
   to install  the pytest-cov module. (And why isn't this part of the 
   requirements file?)
   2. As described the module unit testing appears to require that the 
   module under test and the test itself be accessible in the ansible source 
   tree. Any attempts to execute the test using a test stored outside the 
   Ansible source tree fail. This strikes me as a bit weird/non-optimal. These 
   are - at least for now - strictly inhouse modules that I want to control 
   using git. I don't need or want to clone and maintain the entire Ansible 
   source simply to develop a module. I'm working around this for now by 
   placing my source and test modules into the Ansible source tree as symbolic 
   links.

At any rate thank for pointing me in the right direction!

-steve

On Monday, December 25, 2017 at 12:41:54 PM UTC-8, Serge van Ginderachter 
wrote:
>
>
>
> On 25 December 2017 at 21:33, Stephen Nesbitt <[email protected] 
> <javascript:>> wrote:
>
>> NOOB alert!  I'm struggling to setup a module development environment 
>> that includes support for unit tests and which the module development 
>> environment does not occur within the Ansible source tree directly. That is:
>>
>>    - My module development environment  is an Intellij project with a 
>>    project root at /dev/ansible. Relative to this project root, my module 
>>    sources are located in modules/packaging/os/snaps.py while my unit tests 
>>    are in test/units/modules/packaging/os.test_snaps.py
>>    - The Ansible source lives in /dev/sdks/ansible2.4 which contains a 
>>    clone of the Ansible repository 
>>
>> I've tried the following without success:
>>
>>    - Add test/units/modules and modules to the PYTHONPATH
>>    - source sdks/ansible2.4/hacking/env-setup
>>    - sdks/ansible2.4/test/runner/ansible-tests units --tox --python 3.5 
>>    snaps
>>
>>
>>    - symbolically link modules/packaging/os/snaps.py into the 
>>    ansible2.4/lib/ansible/modules/packaging/os and symbolically link 
>>    test/units/modules/packaging/os.test_snaps.py into 
>>    ansible2.4/test/units/modules/packaging/os/test_snaps.py
>>    - source sdks/ansible2.4/hacking/env-setup
>>    - sdks/ansible2.4/test/runner/ansible-tests units --tox --python 3.5 
>>    snaps
>>    
>> In neither case is my test case found (Target pattern no matched: snaps)
>>
>> Would anyone share how to setup a unit testing supporting module 
>> development environment?
>>
>> Thx,
>>
>> -steve
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ansible Development" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> ​Did you check 
>
>
> http://docs.ansible.com/ansible/latest/intro_installation.html#running-from-source
>
> and 
>
>
> http://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html
>   
> ?
>
>
> Serge
>
> ​
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to