Migrate the v2/tests to use the ansible.compat module

pull/9394/head
Toshio Kuratomi 10 years ago
parent 3f27e5e080
commit a954220957

@ -1,56 +0,0 @@
# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import sys
import unittest
#
# Compat for python2.6
#
if sys.version_info < (2, 7):
try:
# Need unittest2 on python2.6
import unittest2 as unittest
except ImportError:
print('You need unittest2 installed on python2.x')
else:
import unittest
#
# Compat for python2.7
#
# Could use the pypi mock library on py3 as well as py2. They are the same
try:
from unittest.mock import mock_open, patch
except ImportError:
# Python2
from mock import mock_open, patch
try:
import __builtin__
except ImportError:
BUILTINS = 'builtins'
else:
BUILTINS = '__builtin__'

@ -19,12 +19,13 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
from .. compat import unittest from ansible.compat.tests import unittest
from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject
from ansible.errors import AnsibleError from ansible.errors import AnsibleError
from .. compat import BUILTINS, mock_open, patch from ansible.compat.tests import BUILTINS
from ansible.compat.tests.mock import mock_open, patch
class TestErrors(unittest.TestCase): class TestErrors(unittest.TestCase):

@ -19,7 +19,7 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
from .. compat import unittest from ansible.compat.tests import unittest
from ansible.parsing import load_data from ansible.parsing import load_data
from ansible.errors import AnsibleParserError from ansible.errors import AnsibleParserError

@ -21,7 +21,7 @@ __metaclass__ = type
from ansible.parsing.mod_args import ModuleArgsParser from ansible.parsing.mod_args import ModuleArgsParser
from .. compat import unittest from ansible.compat.tests import unittest
class TestModArgsDwim(unittest.TestCase): class TestModArgsDwim(unittest.TestCase):

@ -19,7 +19,7 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
from ... compat import unittest from ansible.compat.tests import unittest
from yaml.scanner import ScannerError from yaml.scanner import ScannerError

@ -21,7 +21,7 @@ __metaclass__ = type
from ansible.playbook.block import Block from ansible.playbook.block import Block
from ansible.playbook.task import Task from ansible.playbook.task import Task
from .. compat import unittest from ansible.compat.tests import unittest
class TestBlock(unittest.TestCase): class TestBlock(unittest.TestCase):

@ -22,7 +22,7 @@ __metaclass__ = type
from ansible.playbook.block import Block from ansible.playbook.block import Block
from ansible.playbook.role import Role from ansible.playbook.role import Role
from ansible.playbook.task import Task from ansible.playbook.task import Task
from .. compat import unittest from ansible.compat.tests import unittest
class TestRole(unittest.TestCase): class TestRole(unittest.TestCase):

@ -20,7 +20,7 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
from ansible.playbook.task import Task from ansible.playbook.task import Task
from .. compat import unittest from ansible.compat.tests import unittest
basic_shell_task = dict( basic_shell_task = dict(
name = 'Test Task', name = 'Test Task',

Loading…
Cancel
Save