mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Somehow, git mv only rm'd test/v2 and didn't add v2/test
This commit is contained in:
51
v2/test/compat.py
Normal file
51
v2/test/compat.py
Normal file
@@ -0,0 +1,51 @@
|
||||
# (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/>.
|
||||
|
||||
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__'
|
||||
|
||||
Reference in New Issue
Block a user