From 40a44ce6ea6f3d3e99cef2931fbe38f9e3bb51ee Mon Sep 17 00:00:00 2001 From: willthames Date: Tue, 3 Dec 2013 11:59:32 +1000 Subject: [PATCH] Ensure test_command tests are actually correct Using ``` assert 'changed' in result ``` doesn't actually check if something is changed, which is presumably the reason for the assertion. What is actually needed is ``` assert result.get('changed') ``` which checks that changed is set and not False. Tests still pass after this change --- test/TestRunner.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/TestRunner.py b/test/TestRunner.py index 2d141f9e8de..67e658cc7d9 100644 --- a/test/TestRunner.py +++ b/test/TestRunner.py @@ -146,26 +146,26 @@ class TestRunner(unittest.TestCase): result = self._run('command', ["/usr/bin/this_does_not_exist", "splat"]) assert 'msg' in result - assert 'failed' in result + assert result.get('failed') result = self._run('shell', ["/bin/echo", "$HOME"]) assert 'failed' not in result assert result['rc'] == 0 result = self._run('command', ["creates='/tmp/ansible command test'", "chdir=/tmp", "touch", "'ansible command test'"]) - assert 'changed' in result + assert result.get('changed') assert result['rc'] == 0 result = self._run('command', ["creates='/tmp/ansible command test'", "false"]) - assert 'skipped' in result + assert result.get('skipped') result = self._run('shell', ["removes=/tmp/ansible\\ command\\ test", "chdir=/tmp", "rm -f 'ansible command test'; echo $?"]) - assert 'changed' in result + assert result.get('changed') assert result['rc'] == 0 assert result['stdout'] == '0' result = self._run('shell', ["removes=/tmp/ansible\\ command\\ test", "false"]) - assert 'skipped' in result + assert result.get('skipped') def test_git(self): self._run('file', ['path=/tmp/gitdemo', 'state=absent'])