From 931073efae902f94a9fee93a94007de73c632331 Mon Sep 17 00:00:00 2001
From: Benjamin Drung <benjamin.drung@profitbricks.com>
Date: Wed, 7 Mar 2018 12:20:13 +0100
Subject: Support unittest.mock from Python >= 3.6 again

Python 3.6 contains unittest.mock which provide all needed functions
(including MagicMock.assert_called). Therefore reverts commit
9d004f6512d0619df895e0aca56143490a34337c partially to only require
mock >= 2.0.0 for Python < 3.6.

Bug: https://github.com/saltstack/salt/issues/46281
Forwarded: https://github.com/saltstack/salt/pull/46415
Signed-off-by: Benjamin Drung <benjamin.drung@profitbricks.com>
---
 tests/support/mock.py | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/tests/support/mock.py b/tests/support/mock.py
index 7ef02e0701..55275583af 100644
--- a/tests/support/mock.py
+++ b/tests/support/mock.py
@@ -5,12 +5,12 @@
     tests.support.mock
     ~~~~~~~~~~~~~~~~~~
 
-    Helper module that wraps `mock` and provides some fake objects in order to
-    properly set the function/class decorators and yet skip the test case's
-    execution.
+    Helper module that wraps :mod:`mock <python3:unittest.mock>` or `mock` and
+    provides some fake objects in order to properly set the function/class
+    decorators and yet skip the test case's execution.
 
-    Note: mock >= 2.0.0 required since unittest.mock does not have
-    MagicMock.assert_called in Python < 3.6.
+    Note: mock >= 2.0.0 is required for Python < 3.6 since unittest.mock in
+    older Python versions does not have MagicMock.assert_called.
 """
 # pylint: disable=unused-import,function-redefined,blacklisted-module,blacklisted-external-module
 
@@ -22,6 +22,12 @@ import errno
 import fnmatch
 import sys
 
+if sys.version_info >= (3, 6):  # noqa
+    import unittest.mock
+
+    sys.modules["mock"] = unittest.mock  # noqa
+
+# isort:imports-thirdparty
 # By these days, we should blowup if mock is not available
 import mock  # pylint: disable=blacklisted-external-import
 import salt.utils.stringutils
@@ -44,6 +50,7 @@ from mock import (
 )
 
 # Import salt libs
+# isort:imports-firstparty
 from salt.ext import six
 
 # pylint: disable=no-name-in-module,no-member
-- 
2.25.1

