summaryrefslogtreecommitdiff
path: root/test/units/mock/procenv.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/units/mock/procenv.py')
-rw-r--r--test/units/mock/procenv.py27
1 files changed, 3 insertions, 24 deletions
diff --git a/test/units/mock/procenv.py b/test/units/mock/procenv.py
index 271a207e..1570c87e 100644
--- a/test/units/mock/procenv.py
+++ b/test/units/mock/procenv.py
@@ -27,7 +27,7 @@ from contextlib import contextmanager
from io import BytesIO, StringIO
from units.compat import unittest
from ansible.module_utils.six import PY3
-from ansible.module_utils._text import to_bytes
+from ansible.module_utils.common.text.converters import to_bytes
@contextmanager
@@ -54,30 +54,9 @@ def swap_stdin_and_argv(stdin_data='', argv_data=tuple()):
sys.argv = real_argv
-@contextmanager
-def swap_stdout():
- """
- context manager that temporarily replaces stdout for tests that need to verify output
- """
- old_stdout = sys.stdout
-
- if PY3:
- fake_stream = StringIO()
- else:
- fake_stream = BytesIO()
-
- try:
- sys.stdout = fake_stream
-
- yield fake_stream
- finally:
- sys.stdout = old_stdout
-
-
class ModuleTestCase(unittest.TestCase):
- def setUp(self, module_args=None):
- if module_args is None:
- module_args = {'_ansible_remote_tmp': '/tmp', '_ansible_keep_remote_files': False}
+ def setUp(self):
+ module_args = {'_ansible_remote_tmp': '/tmp', '_ansible_keep_remote_files': False}
args = json.dumps(dict(ANSIBLE_MODULE_ARGS=module_args))