Use local imports when importing from tests (#2464)

This commit is contained in:
Riccardo Magliocchetti
2024-04-29 20:49:08 +02:00
committed by GitHub
parent 2493258af1
commit de7ce0fb22
5 changed files with 10 additions and 19 deletions

View File

@ -17,13 +17,6 @@ from importlib import import_module
from typing import Any, Callable, Dict
from unittest import mock
from tests.mocks.api_gateway_http_api_event import (
MOCK_LAMBDA_API_GATEWAY_HTTP_API_EVENT,
)
from tests.mocks.api_gateway_proxy_event import (
MOCK_LAMBDA_API_GATEWAY_PROXY_EVENT,
)
from opentelemetry.environment_variables import OTEL_PROPAGATORS
from opentelemetry.instrumentation.aws_lambda import (
_HANDLER,
@ -45,6 +38,11 @@ from opentelemetry.trace.propagation.tracecontext import (
TraceContextTextMapPropagator,
)
from .mocks.api_gateway_http_api_event import (
MOCK_LAMBDA_API_GATEWAY_HTTP_API_EVENT,
)
from .mocks.api_gateway_proxy_event import MOCK_LAMBDA_API_GATEWAY_PROXY_EVENT
class MockLambdaContext:
def __init__(self, aws_request_id, invoked_function_arn):

View File

@ -14,9 +14,6 @@
# pylint:disable=cyclic-import
import grpc
from tests.protobuf import ( # pylint: disable=no-name-in-module
test_server_pb2_grpc,
)
import opentelemetry.instrumentation.grpc
from opentelemetry import trace
@ -41,6 +38,7 @@ from ._client import (
simple_method_future,
)
from ._server import create_test_server
from .protobuf import test_server_pb2_grpc
from .protobuf.test_server_pb2 import Request

View File

@ -17,9 +17,6 @@ import os
from unittest import mock
import grpc
from tests.protobuf import ( # pylint: disable=no-name-in-module
test_server_pb2_grpc,
)
import opentelemetry.instrumentation.grpc
from opentelemetry import trace
@ -44,6 +41,7 @@ from ._client import (
simple_method_future,
)
from ._server import create_test_server
from .protobuf import test_server_pb2_grpc
from .protobuf.test_server_pb2 import Request

View File

@ -13,9 +13,6 @@
# limitations under the License.
import grpc
from tests.protobuf import ( # pylint: disable=no-name-in-module
test_server_pb2_grpc,
)
from opentelemetry import trace
from opentelemetry.instrumentation.grpc import GrpcInstrumentorClient
@ -23,6 +20,7 @@ from opentelemetry.test.test_base import TestBase
from ._client import simple_method
from ._server import create_test_server
from .protobuf import test_server_pb2_grpc
# User defined interceptor. Is used in the tests along with the opentelemetry client interceptor.

View File

@ -24,15 +24,14 @@ from pymemcache.exceptions import (
MemcacheUnknownError,
)
# pylint: disable=import-error,no-name-in-module
from tests.utils import MockSocket, _str
from opentelemetry import trace as trace_api
from opentelemetry.instrumentation.pymemcache import PymemcacheInstrumentor
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.test.test_base import TestBase
from opentelemetry.trace import get_tracer
from .utils import MockSocket, _str
TEST_HOST = "localhost"
TEST_PORT = 117711