diff --git a/test/units/compat/builtins.py b/test/units/compat/builtins.py deleted file mode 100644 index f60ee678228..00000000000 --- a/test/units/compat/builtins.py +++ /dev/null @@ -1,33 +0,0 @@ -# (c) 2014, Toshio Kuratomi -# -# 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 . - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -# -# Compat for python2.7 -# - -# One unittest needs to import builtins via __import__() so we need to have -# the string that represents it -try: - import __builtin__ -except ImportError: - BUILTINS = 'builtins' -else: - BUILTINS = '__builtin__' diff --git a/test/units/errors/test_errors.py b/test/units/errors/test_errors.py index 136a2695099..35689c1c86a 100644 --- a/test/units/errors/test_errors.py +++ b/test/units/errors/test_errors.py @@ -21,7 +21,6 @@ __metaclass__ = type from units.compat import unittest -from units.compat.builtins import BUILTINS from units.compat.mock import mock_open, patch from ansible.errors import AnsibleError from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject @@ -87,7 +86,7 @@ class TestErrors(unittest.TestCase): m = mock_open() m.return_value.readlines.return_value = ['this is line 1\n'] - with patch('{0}.open'.format(BUILTINS), m): + with patch('builtins.open', m): # this line will be found in the file self.obj.ansible_pos = ('foo.yml', 1, 1) e = AnsibleError(self.message, self.obj) @@ -110,7 +109,7 @@ class TestErrors(unittest.TestCase): m = mock_open() m.return_value.readlines.return_value = ['this line has unicode \xf0\x9f\x98\xa8 in it!\n'] - with patch('{0}.open'.format(BUILTINS), m): + with patch('builtins.open', m): # this line will be found in the file self.obj.ansible_pos = ('foo.yml', 1, 1) e = AnsibleError(self.unicode_message, self.obj) @@ -125,7 +124,7 @@ class TestErrors(unittest.TestCase): m = mock_open() m.return_value.readlines.return_value = ['this is line 1\n', 'this is line 2\n', 'this is line 3\n'] - with patch('{0}.open'.format(BUILTINS), m): + with patch('builtins.open', m): # If the error occurs in the last line of the file, use the correct index to get the line # and avoid the IndexError self.obj.ansible_pos = ('foo.yml', 4, 1) @@ -141,7 +140,7 @@ class TestErrors(unittest.TestCase): m = mock_open() m.return_value.readlines.return_value = ['this is line 1\n', 'this is line 2\n', 'this is line 3\n', ' \n', ' \n', ' '] - with patch('{0}.open'.format(BUILTINS), m): + with patch('builtins.open', m): self.obj.ansible_pos = ('foo.yml', 5, 1) e = AnsibleError(self.message, self.obj) self.assertEqual( diff --git a/test/units/plugins/test_plugins.py b/test/units/plugins/test_plugins.py index c9d80cda6d4..18dbce98dad 100644 --- a/test/units/plugins/test_plugins.py +++ b/test/units/plugins/test_plugins.py @@ -23,7 +23,6 @@ __metaclass__ = type import os from units.compat import unittest -from units.compat.builtins import BUILTINS from units.compat.mock import patch, MagicMock from ansible.plugins.loader import PluginLoader, PluginPathContext @@ -54,7 +53,7 @@ class TestErrors(unittest.TestCase): bar.bam = bam foo.return_value.bar = bar pl = PluginLoader('test', 'foo.bar.bam', 'test', 'test_plugin') - with patch('{0}.__import__'.format(BUILTINS), foo): + with patch('builtins.__import__', foo): self.assertEqual(pl._get_package_paths(), ['/path/to/my/foo/bar/bam']) def test_plugins__get_paths(self):