mardi 27 février 2018

Set a variable based on a py.test (testinfra) check output

I am trying to make a testinfra test file more portable, I'd like to use a single file to handle tests for either a prod / dev or test env. For this I need to get a value from the remote tested machine, which I get by :

def test_ACD_GRAIN(host):
    grain = host.salt("grains.item", "client_NAME")
    assert grain['client_NAME'] == "test"

I'd need to use this grain['client_NAME'] value in different part of the test file, therefore I'd like to store it in a variable.

Anyway to do this ?

Aucun commentaire:

Enregistrer un commentaire