Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tests/contrib/openai_agents/test_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import nexusrpc
import pydantic
import pytest
from agents import (
Agent,
AgentBase,
Expand Down Expand Up @@ -114,6 +113,11 @@
from tests.helpers import assert_eventually, new_worker
from tests.helpers.nexus import create_nexus_endpoint, make_nexus_endpoint_name

# Passing through because Python <=3.12 has an import bug at
# https://github.com/python/cpython/issues/91351
with workflow.unsafe.imports_passed_through():
import pytest


class StaticTestModel(TestModel):
__test__ = False
Expand Down
8 changes: 6 additions & 2 deletions tests/contrib/openai_agents/test_openai_replay.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from pathlib import Path

import pytest

from temporalio import workflow
from temporalio.client import WorkflowHistory
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
from temporalio.worker import Replayer
Expand All @@ -15,6 +14,11 @@
ToolsWorkflow,
)

# Passing through because Python <=3.12 has an import bug at
# https://github.com/python/cpython/issues/91351
with workflow.unsafe.imports_passed_through():
import pytest


@pytest.mark.parametrize(
"file_name",
Expand Down
6 changes: 5 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from unittest import mock

import google.protobuf.any_pb2
import pytest
from google.protobuf import json_format

import temporalio.api.common.v1
Expand Down Expand Up @@ -102,6 +101,11 @@
KSWorkflowParams,
)

# Passing through because Python <=3.12 has an import bug at
# https://github.com/python/cpython/issues/91351
with workflow.unsafe.imports_passed_through():
import pytest


async def test_start_id_reuse(
client: Client, worker: ExternalWorker, env: WorkflowEnvironment
Expand Down
7 changes: 5 additions & 2 deletions tests/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
import itertools
from typing import Any, Callable, Sequence, Set, Type, get_type_hints

import pytest

from temporalio import workflow
from temporalio.common import RawValue, VersioningBehavior

# Passing through because Python <=3.12 has an import bug at
# https://github.com/python/cpython/issues/91351
with workflow.unsafe.imports_passed_through():
import pytest


class GoodDefnBase:
@workflow.run
Expand Down
7 changes: 5 additions & 2 deletions tests/worker/test_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
from time import sleep
from typing import Any, Callable, List, NoReturn, Optional, Sequence, Type

import pytest

import temporalio.api.workflowservice.v1
from temporalio import activity, workflow
from temporalio.client import (
Expand Down Expand Up @@ -52,6 +50,11 @@
kitchen_sink_retry_policy,
)

# Passing through because Python <=3.12 has an import bug at
# https://github.com/python/cpython/issues/91351
with workflow.unsafe.imports_passed_through():
import pytest

_default_shared_state_manager = SharedStateManager.create_from_multiprocessing(
multiprocessing.Manager()
)
Expand Down
7 changes: 5 additions & 2 deletions tests/worker/test_interceptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from datetime import timedelta
from typing import Any, Callable, List, NoReturn, Optional, Tuple, Type

import pytest

from temporalio import activity, workflow
from temporalio.client import Client, WorkflowUpdateFailedError
from temporalio.exceptions import ApplicationError, NexusOperationError
Expand Down Expand Up @@ -32,6 +30,11 @@
from temporalio.worker._interceptor import StartNexusOperationInput
from tests.helpers.nexus import create_nexus_endpoint, make_nexus_endpoint_name

# Passing through because Python <=3.12 has an import bug at
# https://github.com/python/cpython/issues/91351
with workflow.unsafe.imports_passed_through():
import pytest

interceptor_traces: List[Tuple[str, Any]] = []


Expand Down
7 changes: 5 additions & 2 deletions tests/worker/test_replayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from pathlib import Path
from typing import Any, Dict, Optional, Type

import pytest

from temporalio import activity, workflow
from temporalio.client import Client, WorkflowFailureError, WorkflowHistory
from temporalio.exceptions import ApplicationError
Expand All @@ -29,6 +27,11 @@
SignalsActivitiesTimersUpdatesTracingWorkflow,
)

# Passing through because Python <=3.12 has an import bug at
# https://github.com/python/cpython/issues/91351
with workflow.unsafe.imports_passed_through():
import pytest


@activity.defn
async def say_hello(name: str) -> str:
Expand Down
7 changes: 5 additions & 2 deletions tests/worker/test_update_with_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from typing import Any, Mapping, Optional, Union
from unittest.mock import patch

import pytest

import temporalio.api.common.v1
import temporalio.api.workflowservice.v1
from temporalio import activity, workflow
Expand All @@ -35,6 +33,11 @@
new_worker,
)

# Passing through because Python <=3.12 has an import bug at
# https://github.com/python/cpython/issues/91351
with workflow.unsafe.imports_passed_through():
import pytest


@activity.defn
async def activity_called_by_update() -> None:
Expand Down
6 changes: 5 additions & 1 deletion tests/worker/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from urllib.request import urlopen

import nexusrpc
import pytest

import temporalio.api.enums.v1
import temporalio.nexus
Expand Down Expand Up @@ -60,6 +59,11 @@
)
from tests.helpers.nexus import create_nexus_endpoint, make_nexus_endpoint_name

# Passing through because Python <=3.12 has an import bug at
# https://github.com/python/cpython/issues/91351
with workflow.unsafe.imports_passed_through():
import pytest


def test_load_default_worker_binary_id():
# Just run it twice and confirm it didn't change
Expand Down
6 changes: 5 additions & 1 deletion tests/worker/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
from urllib.request import urlopen

import pydantic
import pytest
from google.protobuf.timestamp_pb2 import Timestamp
from typing_extensions import Literal, Protocol, runtime_checkable

Expand Down Expand Up @@ -156,6 +155,11 @@
external_wait_cancel,
)

# Passing through because Python <=3.12 has an import bug at
# https://github.com/python/cpython/issues/91351
with workflow.unsafe.imports_passed_through():
import pytest


@workflow.defn
class HelloWorkflow:
Expand Down
7 changes: 5 additions & 2 deletions tests/worker/workflow_sandbox/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
from enum import IntEnum
from typing import Callable, Dict, List, Optional, Sequence, Set, Type

import pytest

from temporalio import activity, workflow
from temporalio.client import Client, WorkflowFailureError, WorkflowHandle
from temporalio.exceptions import ApplicationError
Expand All @@ -29,6 +27,11 @@
from tests.worker.workflow_sandbox.testmodules import stateful_module
from tests.worker.workflow_sandbox.testmodules.proto import SomeMessage

# Passing through because Python <=3.12 has an import bug at
# https://github.com/python/cpython/issues/91351
with workflow.unsafe.imports_passed_through():
import pytest

global_state = ["global orig"]
# We just access os.name in here to show we _can_. It's access-restricted at
# runtime only
Expand Down
Loading