summaryrefslogtreecommitdiff
path: root/test/units/executor/module_common/test_module_common.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/units/executor/module_common/test_module_common.py')
-rw-r--r--test/units/executor/module_common/test_module_common.py39
1 files changed, 12 insertions, 27 deletions
diff --git a/test/units/executor/module_common/test_module_common.py b/test/units/executor/module_common/test_module_common.py
index fa6add8c..6e2a4956 100644
--- a/test/units/executor/module_common/test_module_common.py
+++ b/test/units/executor/module_common/test_module_common.py
@@ -27,7 +27,6 @@ import ansible.errors
from ansible.executor import module_common as amc
from ansible.executor.interpreter_discovery import InterpreterDiscoveryRequiredError
-from ansible.module_utils.six import PY2
class TestStripComments:
@@ -44,15 +43,16 @@ class TestStripComments:
assert amc._strip_comments(all_comments) == u""
def test_all_whitespace(self):
- # Note: Do not remove the spaces on the blank lines below. They're
- # test data to show that the lines get removed despite having spaces
- # on them
- all_whitespace = u"""
-
-
-
-\t\t\r\n
- """ # nopep8
+ all_whitespace = (
+ '\n'
+ ' \n'
+ '\n'
+ ' \n'
+ '\t\t\r\n'
+ '\n'
+ ' '
+ )
+
assert amc._strip_comments(all_whitespace) == u""
def test_somewhat_normal(self):
@@ -80,31 +80,16 @@ class TestSlurp:
def test_slurp_file(self, mocker):
mocker.patch('os.path.exists', side_effect=lambda x: True)
m = mocker.mock_open(read_data='This is a test')
- if PY2:
- mocker.patch('__builtin__.open', m)
- else:
- mocker.patch('builtins.open', m)
+ mocker.patch('builtins.open', m)
assert amc._slurp('some_file') == 'This is a test'
def test_slurp_file_with_newlines(self, mocker):
mocker.patch('os.path.exists', side_effect=lambda x: True)
m = mocker.mock_open(read_data='#!/usr/bin/python\ndef test(args):\nprint("hi")\n')
- if PY2:
- mocker.patch('__builtin__.open', m)
- else:
- mocker.patch('builtins.open', m)
+ mocker.patch('builtins.open', m)
assert amc._slurp('some_file') == '#!/usr/bin/python\ndef test(args):\nprint("hi")\n'
-@pytest.fixture
-def templar():
- class FakeTemplar:
- def template(self, template_string, *args, **kwargs):
- return template_string
-
- return FakeTemplar()
-
-
class TestGetShebang:
"""Note: We may want to change the API of this function in the future. It isn't a great API"""
def test_no_interpreter_set(self, templar):