mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Make unittest compatible with python <= 2.6
This commit is contained in:
parent
313f26f866
commit
e00d657362
1 changed files with 18 additions and 6 deletions
|
@ -294,12 +294,20 @@ class TestModuleUtilsBasicHelpers(unittest.TestCase):
|
|||
ssh_output = self.module._heuristic_log_sanitize(ssh_data)
|
||||
|
||||
# Basic functionality: Successfully hid the password
|
||||
self.assertNotIn('pas:word', url_output)
|
||||
self.assertNotIn('pas:word', ssh_output)
|
||||
try:
|
||||
self.assertNotIn('pas:word', url_output)
|
||||
self.assertNotIn('pas:word', ssh_output)
|
||||
|
||||
# Slightly more advanced, we hid all of the password despite the ":"
|
||||
self.assertNotIn('pas', url_output)
|
||||
self.assertNotIn('pas', ssh_output)
|
||||
# Slightly more advanced, we hid all of the password despite the ":"
|
||||
self.assertNotIn('pas', url_output)
|
||||
self.assertNotIn('pas', ssh_output)
|
||||
except AttributeError:
|
||||
# python2.6 or less's unittest
|
||||
self.assertFalse('pas:word' in url_output, '%s is present in %s' % ('"pas:word"', url_output))
|
||||
self.assertFalse('pas:word' in ssh_output, '%s is present in %s' % ('"pas:word"', ssh_output))
|
||||
|
||||
self.assertFalse('pas' in url_output, '%s is present in %s' % ('"pas"', url_output))
|
||||
self.assertFalse('pas' in ssh_output, '%s is present in %s' % ('"pas"', ssh_output))
|
||||
|
||||
# In this implementation we replace the password with 8 "*" which is
|
||||
# also the length of our password. The url fields should be able to
|
||||
|
@ -313,7 +321,11 @@ class TestModuleUtilsBasicHelpers(unittest.TestCase):
|
|||
# the data, though:
|
||||
self.assertTrue(ssh_output.startswith("{'"))
|
||||
self.assertTrue(ssh_output.endswith("'}}}}"))
|
||||
self.assertIn(":********@foo.com/data',", ssh_output)
|
||||
try:
|
||||
self.assertIn(":********@foo.com/data',", ssh_output)
|
||||
except AttributeError:
|
||||
# python2.6 or less's unittest
|
||||
self.assertTrue(":********@foo.com/data'," in ssh_output, '%s is not present in %s' % (":********@foo.com/data',", ssh_output))
|
||||
|
||||
# The overzealous-ness here may lead to us changing the algorithm in
|
||||
# the future. We could make it consume less of the data (with the
|
||||
|
|
Loading…
Reference in a new issue