Terminate gpg-agent after each test.

This is actual for gnupg 2.1 that requires the agent and starts it
automatically. But since each test creates a new keystore tests become
fail after the first one starts gpg-agent.
This commit is contained in:
Dmitry Kuzmenko 2017-05-25 11:23:21 +03:00
parent 460af48f1f
commit 67e0c3e166

View file

@ -237,6 +237,19 @@ class DecryptGPGPillarTest(ModuleCase):
@classmethod
def tearDownClass(cls):
cmd = ['gpg-connect-agent', '--homedir', GPG_HOMEDIR]
try:
log.debug('Killing gpg-agent using: %s', cmd)
output = subprocess.Popen(cmd,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
shell=False).communicate(input=six.b('KILLAGENT'))[0]
log.debug('Result:\n%s', output)
except OSError:
log.debug('No need to kill: old gnupg doesn\'t start the agent.')
pass
if cls.created_gpg_homedir:
try:
shutil.rmtree(GPG_HOMEDIR)