We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Switch unit tests from `unittest.mock` to SDK & in-memory exporter
See https://github.com/open-telemetry/opentelemetry-python/pull/290#issuecomment-558091283.
Currently tests are cumbersome to write and actually we probably don't want to test which API calls are made but what Spans would result in most cases. For this a SDK with in-memory exporter would be better than using `unittest.mock`.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `ext/opentelemetry-ext-testutil/src/opentelemetry/ext/testutil/wsgitestutil.py`
Content:
```
1 import io
2 import unittest
3 import unittest.mock as mock
4 import wsgiref.util as wsgiref_util
5 
6 from opentelemetry import trace as trace_api
7 
8 
9 class WsgiTestBase(unittest.TestCase):
10     def setUp(self):
11         self.span = mock.create_autospec(trace_api.Span, spec_set=True)
12         tracer = trace_api.Tracer()
13         self.get_tracer_patcher = mock.patch.object(
14             trace_api.TracerSource,
15             "get_tracer",
16             autospec=True,
17             spec_set=True,
18             return_value=tracer,
19         )
20         self.get_tracer_patcher.start()
21 
22         self.start_span_patcher = mock.patch.object(
23             tracer,
24             "start_span",
25             autospec=True,
26             spec_set=True,
27             return_value=self.span,
28         )
29         self.start_span = self.start_span_patcher.start()
30         self.write_buffer = io.BytesIO()
31         self.write = self.write_buffer.write
32 
33         self.environ = {}
34         wsgiref_util.setup_testing_defaults(self.environ)
35 
36         self.status = None
37         self.response_headers = None
38         self.exc_info = None
39 
40     def tearDown(self):
41         self.get_tracer_patcher.stop()
42         self.start_span_patcher.stop()
43 
44     def start_response(self, status, response_headers, exc_info=None):
45         self.status = status
46         self.response_headers = response_headers
47         self.exc_info = exc_info
48         return self.write
49
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/ext/opentelemetry-ext-testutil/src/opentelemetry/ext/testutil/wsgitestutil.py b/ext/opentelemetry-ext-testutil/src/opentelemetry/ext/testutil/wsgitestutil.py
--- a/ext/opentelemetry-ext-testutil/src/opentelemetry/ext/testutil/wsgitestutil.py
+++ b/ext/opentelemetry-ext-testutil/src/opentelemetry/ext/testutil/wsgitestutil.py
@@ -1,32 +1,38 @@
 import io
 import unittest
-import unittest.mock as mock
 import wsgiref.util as wsgiref_util
+from importlib import reload
 
 from opentelemetry import trace as trace_api
+from opentelemetry.sdk.trace import TracerSource, export
+from opentelemetry.sdk.trace.export.in_memory_span_exporter import (
+    InMemorySpanExporter,
+)
+
+_MEMORY_EXPORTER = None
 
 
 class WsgiTestBase(unittest.TestCase):
-    def setUp(self):
-        self.span = mock.create_autospec(trace_api.Span, spec_set=True)
-        tracer = trace_api.Tracer()
-        self.get_tracer_patcher = mock.patch.object(
-            trace_api.TracerSource,
-            "get_tracer",
-            autospec=True,
-            spec_set=True,
-            return_value=tracer,
-        )
-        self.get_tracer_patcher.start()
-
-        self.start_span_patcher = mock.patch.object(
-            tracer,
-            "start_span",
-            autospec=True,
-            spec_set=True,
-            return_value=self.span,
+    @classmethod
+    def setUpClass(cls):
+        global _MEMORY_EXPORTER  # pylint:disable=global-statement
+        trace_api.set_preferred_tracer_source_implementation(
+            lambda T: TracerSource()
         )
-        self.start_span = self.start_span_patcher.start()
+        tracer_source = trace_api.tracer_source()
+        _MEMORY_EXPORTER = InMemorySpanExporter()
+        span_processor = export.SimpleExportSpanProcessor(_MEMORY_EXPORTER)
+        tracer_source.add_span_processor(span_processor)
+
+    @classmethod
+    def tearDownClass(cls):
+        reload(trace_api)
+
+    def setUp(self):
+
+        self.memory_exporter = _MEMORY_EXPORTER
+        self.memory_exporter.clear()
+
         self.write_buffer = io.BytesIO()
         self.write = self.write_buffer.write
 
@@ -37,10 +43,6 @@
         self.response_headers = None
         self.exc_info = None
 
-    def tearDown(self):
-        self.get_tracer_patcher.stop()
-        self.start_span_patcher.stop()
-
     def start_response(self, status, response_headers, exc_info=None):
         self.status = status
         self.response_headers = response_headers

{"golden_diff": "diff --git a/ext/opentelemetry-ext-testutil/src/opentelemetry/ext/testutil/wsgitestutil.py b/ext/opentelemetry-ext-testutil/src/opentelemetry/ext/testutil/wsgitestutil.py\n--- a/ext/opentelemetry-ext-testutil/src/opentelemetry/ext/testutil/wsgitestutil.py\n+++ b/ext/opentelemetry-ext-testutil/src/opentelemetry/ext/testutil/wsgitestutil.py\n@@ -1,32 +1,38 @@\n import io\n import unittest\n-import unittest.mock as mock\n import wsgiref.util as wsgiref_util\n+from importlib import reload\n \n from opentelemetry import trace as trace_api\n+from opentelemetry.sdk.trace import TracerSource, export\n+from opentelemetry.sdk.trace.export.in_memory_span_exporter import (\n+    InMemorySpanExporter,\n+)\n+\n+_MEMORY_EXPORTER = None\n \n \n class WsgiTestBase(unittest.TestCase):\n-    def setUp(self):\n-        self.span = mock.create_autospec(trace_api.Span, spec_set=True)\n-        tracer = trace_api.Tracer()\n-        self.get_tracer_patcher = mock.patch.object(\n-            trace_api.TracerSource,\n-            \"get_tracer\",\n-            autospec=True,\n-            spec_set=True,\n-            return_value=tracer,\n-        )\n-        self.get_tracer_patcher.start()\n-\n-        self.start_span_patcher = mock.patch.object(\n-            tracer,\n-            \"start_span\",\n-            autospec=True,\n-            spec_set=True,\n-            return_value=self.span,\n+    @classmethod\n+    def setUpClass(cls):\n+        global _MEMORY_EXPORTER  # pylint:disable=global-statement\n+        trace_api.set_preferred_tracer_source_implementation(\n+            lambda T: TracerSource()\n         )\n-        self.start_span = self.start_span_patcher.start()\n+        tracer_source = trace_api.tracer_source()\n+        _MEMORY_EXPORTER = InMemorySpanExporter()\n+        span_processor = export.SimpleExportSpanProcessor(_MEMORY_EXPORTER)\n+        tracer_source.add_span_processor(span_processor)\n+\n+    @classmethod\n+    def tearDownClass(cls):\n+        reload(trace_api)\n+\n+    def setUp(self):\n+\n+        self.memory_exporter = _MEMORY_EXPORTER\n+        self.memory_exporter.clear()\n+\n         self.write_buffer = io.BytesIO()\n         self.write = self.write_buffer.write\n \n@@ -37,10 +43,6 @@\n         self.response_headers = None\n         self.exc_info = None\n \n-    def tearDown(self):\n-        self.get_tracer_patcher.stop()\n-        self.start_span_patcher.stop()\n-\n     def start_response(self, status, response_headers, exc_info=None):\n         self.status = status\n         self.response_headers = response_headers\n", "issue": "Switch unit tests from `unittest.mock` to SDK & in-memory exporter\nSee https://github.com/open-telemetry/opentelemetry-python/pull/290#issuecomment-558091283.\r\nCurrently tests are cumbersome to write and actually we probably don't want to test which API calls are made but what Spans would result in most cases. For this a SDK with in-memory exporter would be better than using `unittest.mock`.\n", "before_files": [{"content": "import io\nimport unittest\nimport unittest.mock as mock\nimport wsgiref.util as wsgiref_util\n\nfrom opentelemetry import trace as trace_api\n\n\nclass WsgiTestBase(unittest.TestCase):\n    def setUp(self):\n        self.span = mock.create_autospec(trace_api.Span, spec_set=True)\n        tracer = trace_api.Tracer()\n        self.get_tracer_patcher = mock.patch.object(\n            trace_api.TracerSource,\n            \"get_tracer\",\n            autospec=True,\n            spec_set=True,\n            return_value=tracer,\n        )\n        self.get_tracer_patcher.start()\n\n        self.start_span_patcher = mock.patch.object(\n            tracer,\n            \"start_span\",\n            autospec=True,\n            spec_set=True,\n            return_value=self.span,\n        )\n        self.start_span = self.start_span_patcher.start()\n        self.write_buffer = io.BytesIO()\n        self.write = self.write_buffer.write\n\n        self.environ = {}\n        wsgiref_util.setup_testing_defaults(self.environ)\n\n        self.status = None\n        self.response_headers = None\n        self.exc_info = None\n\n    def tearDown(self):\n        self.get_tracer_patcher.stop()\n        self.start_span_patcher.stop()\n\n    def start_response(self, status, response_headers, exc_info=None):\n        self.status = status\n        self.response_headers = response_headers\n        self.exc_info = exc_info\n        return self.write\n", "path": "ext/opentelemetry-ext-testutil/src/opentelemetry/ext/testutil/wsgitestutil.py"}], "after_files": [{"content": "import io\nimport unittest\nimport wsgiref.util as wsgiref_util\nfrom importlib import reload\n\nfrom opentelemetry import trace as trace_api\nfrom opentelemetry.sdk.trace import TracerSource, export\nfrom opentelemetry.sdk.trace.export.in_memory_span_exporter import (\n    InMemorySpanExporter,\n)\n\n_MEMORY_EXPORTER = None\n\n\nclass WsgiTestBase(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        global _MEMORY_EXPORTER  # pylint:disable=global-statement\n        trace_api.set_preferred_tracer_source_implementation(\n            lambda T: TracerSource()\n        )\n        tracer_source = trace_api.tracer_source()\n        _MEMORY_EXPORTER = InMemorySpanExporter()\n        span_processor = export.SimpleExportSpanProcessor(_MEMORY_EXPORTER)\n        tracer_source.add_span_processor(span_processor)\n\n    @classmethod\n    def tearDownClass(cls):\n        reload(trace_api)\n\n    def setUp(self):\n\n        self.memory_exporter = _MEMORY_EXPORTER\n        self.memory_exporter.clear()\n\n        self.write_buffer = io.BytesIO()\n        self.write = self.write_buffer.write\n\n        self.environ = {}\n        wsgiref_util.setup_testing_defaults(self.environ)\n\n        self.status = None\n        self.response_headers = None\n        self.exc_info = None\n\n    def start_response(self, status, response_headers, exc_info=None):\n        self.status = status\n        self.response_headers = response_headers\n        self.exc_info = exc_info\n        return self.write\n", "path": "ext/opentelemetry-ext-testutil/src/opentelemetry/ext/testutil/wsgitestutil.py"}]}