Repository: opentracing/opentracing-python (language: python)

Issue:
Stop requiring mock when unittest.mock is available
Hello,

The "mock" PyPI package is a backport of Python3.3's unittest.mock for old Python versions.
It is being progressively removed from distributions.
Do you intend opentracing-python to be compatible with Python < 3.3?

If yes, please use "mock" only as fallback:

```python
try:
    from unittest import mock
except ImportError:
    import mock
```

And in setup.py, require "mock" only in < 3.3:

```python
            'mock;python_version<"3.3"',
```

If not, you can directly use unittest.mock:

```python
from unittest import mock
```

And remove the dependency on "mock" in setup.py.

See for example this page which documents the removal of "mock" in
Fedora: https://fedoraproject.org/wiki/Changes/DeprecatePythonMock



Discussion / hints:

Fix patch:
diff --git a/opentracing/harness/api_check.py b/opentracing/harness/api_check.py
index f917620..de90e1e 100644
--- a/opentracing/harness/api_check.py
+++ b/opentracing/harness/api_check.py
@@ -14,7 +14,11 @@
 
 from __future__ import absolute_import
 
-import mock
+try:
+    from unittest import mock
+except ImportError:
+    import mock
+
 import time
 import pytest
 
diff --git a/opentracing/harness/scope_check.py b/opentracing/harness/scope_check.py
index b70df48..ede172a 100644
--- a/opentracing/harness/scope_check.py
+++ b/opentracing/harness/scope_check.py
@@ -19,7 +19,10 @@
 # THE SOFTWARE.
 from __future__ import absolute_import
 
-import mock
+try:
+    from unittest import mock
+except ImportError:
+    import mock
 
 from opentracing.span import Span
 
diff --git a/setup.py b/setup.py
index d0879eb..1652113 100644
--- a/setup.py
+++ b/setup.py
@@ -33,7 +33,7 @@
         'tests': [
             'flake8',
             'flake8-quotes',
-            'mock',
+            'mock;python_version<"3.3"',
             'pytest',
             'pytest-cov',
             'pytest-mock',


Test patch:
diff --git a/tests/test_globaltracer.py b/tests/test_globaltracer.py
index aa0227c..61dec6a 100644
--- a/tests/test_globaltracer.py
+++ b/tests/test_globaltracer.py
@@ -14,8 +14,11 @@
 
 from __future__ import absolute_import
 import pytest
-import mock
 import opentracing
+try:
+    from unittest import mock
+except ImportError:
+    import mock
 
 
 def teardown_function(function):
diff --git a/tests/test_noop_span.py b/tests/test_noop_span.py
index 0753d32..cc36e8d 100644
--- a/tests/test_noop_span.py
+++ b/tests/test_noop_span.py
@@ -13,9 +13,12 @@
 # limitations under the License.
 
 from __future__ import absolute_import
-import mock
 import time
 import types
+try:
+    from unittest import mock
+except ImportError:
+    import mock
 from opentracing import child_of
 from opentracing import Format
 from opentracing import Tracer
diff --git a/tests/test_scope.py b/tests/test_scope.py
index 5db33b1..01c3496 100644
--- a/tests/test_scope.py
+++ b/tests/test_scope.py
@@ -20,8 +20,11 @@
 
 from __future__ import absolute_import
 
-import mock
 import types
+try:
+    from unittest import mock
+except ImportError:
+    import mock
 
 from opentracing.scope_manager import ScopeManager
 from opentracing.tracer import Tracer