|
14 | 14 |
|
15 | 15 | from http import HTTPStatus
|
16 | 16 |
|
17 |
| -from opentelemetry.instrumentation.utils import http_status_to_status_code |
| 17 | +from opentelemetry.instrumentation.utils import ( |
| 18 | + _python_path_without_directory, |
| 19 | + http_status_to_status_code, |
| 20 | +) |
18 | 21 | from opentelemetry.test.test_base import TestBase
|
19 | 22 | from opentelemetry.trace import StatusCode
|
20 | 23 |
|
@@ -111,3 +114,41 @@ def test_http_status_to_status_code_server(self):
|
111 | 114 | int(status_code), server_span=True
|
112 | 115 | )
|
113 | 116 | self.assertEqual(actual, expected, status_code)
|
| 117 | + |
| 118 | + def test_remove_current_directory_from_python_path_windows(self): |
| 119 | + directory = r"c:\users\Trayvon Martin\workplace\opentelemetry-python-contrib\opentelemetry-instrumentation\src\opentelemetry\instrumentation\auto_instrumentation" |
| 120 | + path_separator = r";" |
| 121 | + python_path = r"c:\users\Trayvon Martin\workplace\opentelemetry-python-contrib\opentelemetry-instrumentation\src\opentelemetry\instrumentation\auto_instrumentation;C:\Users\trayvonmartin\workplace" |
| 122 | + actual_python_path = _python_path_without_directory( |
| 123 | + python_path, directory, path_separator |
| 124 | + ) |
| 125 | + expected_python_path = r"C:\Users\trayvonmartin\workplace" |
| 126 | + self.assertEqual(actual_python_path, expected_python_path) |
| 127 | + |
| 128 | + def test_remove_current_directory_from_python_path_linux(self): |
| 129 | + directory = r"/home/georgefloyd/workplace/opentelemetry-python-contrib/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation" |
| 130 | + path_separator = r":" |
| 131 | + python_path = r"/home/georgefloyd/workplace/opentelemetry-python-contrib/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation:/home/georgefloyd/workplace" |
| 132 | + actual_python_path = _python_path_without_directory( |
| 133 | + python_path, directory, path_separator |
| 134 | + ) |
| 135 | + expected_python_path = r"/home/georgefloyd/workplace" |
| 136 | + self.assertEqual(actual_python_path, expected_python_path) |
| 137 | + |
| 138 | + def test_remove_current_directory_from_python_path_windows_only_path(self): |
| 139 | + directory = r"c:\users\Charleena Lyles\workplace\opentelemetry-python-contrib\opentelemetry-instrumentation\src\opentelemetry\instrumentation\auto_instrumentation" |
| 140 | + path_separator = r";" |
| 141 | + python_path = r"c:\users\Charleena Lyles\workplace\opentelemetry-python-contrib\opentelemetry-instrumentation\src\opentelemetry\instrumentation\auto_instrumentation" |
| 142 | + actual_python_path = _python_path_without_directory( |
| 143 | + python_path, directory, path_separator |
| 144 | + ) |
| 145 | + self.assertEqual(actual_python_path, python_path) |
| 146 | + |
| 147 | + def test_remove_current_directory_from_python_path_linux_only_path(self): |
| 148 | + directory = r"/home/SandraBland/workplace/opentelemetry-python-contrib/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation" |
| 149 | + path_separator = r":" |
| 150 | + python_path = r"/home/SandraBland/workplace/opentelemetry-python-contrib/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation" |
| 151 | + actual_python_path = _python_path_without_directory( |
| 152 | + python_path, directory, path_separator |
| 153 | + ) |
| 154 | + self.assertEqual(actual_python_path, python_path) |
0 commit comments