1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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

This commit is contained in:
Toshio Kuratomi 2014-10-21 01:14:30 -04:00
parent 3f27e5e080
commit a954220957
8 changed files with 9 additions and 64 deletions

View file

@ -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__'

View file

@ -19,12 +19,13 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from .. compat import unittest
from ansible.compat.tests import unittest
from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject
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):

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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