Skip to content

Commit 707473a

Browse files
committed
Try pytest plain asserts on 3.9
1 parent 08c5fcc commit 707473a

File tree

3 files changed

+14
-22
lines changed

3 files changed

+14
-22
lines changed

Diff for: .github/workflows/ci.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ jobs:
1515
python: ["3.9", "3.13"]
1616
os: [ubuntu-latest, ubuntu-arm, macos-intel, macos-arm, windows-latest]
1717
include:
18+
# On 3.9 there is a problem with import errors caused by pytests' loader that surface due
19+
# to a bug in CPython, so we avoid using the assert rewriter.
20+
- python: "3.9"
21+
pytestExtraArgs: "--assert=plain"
1822
- os: ubuntu-latest
1923
python: "3.13"
2024
docsTarget: true
@@ -54,13 +58,13 @@ jobs:
5458
- run: poe lint
5559
- run: poe build-develop
5660
- run: mkdir junit-xml
57-
- run: poe test -s --junit-xml=junit-xml/${{ matrix.python }}--${{ matrix.os }}.xml
61+
- run: poe test ${{matrix.pytestExtraArgs}} -s --junit-xml=junit-xml/${{ matrix.python }}--${{ matrix.os }}.xml
5862
# Time skipping doesn't yet support ARM
5963
- if: ${{ !endsWith(matrix.os, '-arm') }}
60-
run: poe test -s --workflow-environment time-skipping --junit-xml=junit-xml/${{ matrix.python }}--${{ matrix.os }}--time-skipping.xml
64+
run: poe test ${{matrix.pytestExtraArgs}} -s --workflow-environment time-skipping --junit-xml=junit-xml/${{ matrix.python }}--${{ matrix.os }}--time-skipping.xml
6165
# Check cloud if proper target and not on fork
6266
- if: ${{ matrix.cloudTestTarget && (github.event.pull_request.head.repo.full_name == '' || github.event.pull_request.head.repo.full_name == 'temporalio/sdk-python') }}
63-
run: poe test -s -k test_cloud_client --junit-xml=junit-xml/${{ matrix.python }}--${{ matrix.os }}--cloud.xml
67+
run: poe test ${{matrix.pytestExtraArgs}} -s -k test_cloud_client --junit-xml=junit-xml/${{ matrix.python }}--${{ matrix.os }}--cloud.xml
6468
env:
6569
TEMPORAL_CLIENT_CLOUD_API_KEY: ${{ secrets.TEMPORAL_CLIENT_CLOUD_API_KEY }}
6670
TEMPORAL_CLIENT_CLOUD_API_VERSION: 2024-05-13-00

Diff for: tests/testing/test_workflow.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import platform
3+
import sys
34
import uuid
45
from datetime import datetime, timedelta, timezone
56
from time import monotonic
@@ -223,7 +224,9 @@ def assert_proper_error(err: Optional[BaseException]) -> None:
223224
# In unsandboxed workflows, this message has extra diff info appended
224225
# due to pytest's custom loader that does special assert tricks. But in
225226
# sandboxed workflows, this just has the first line.
226-
assert err.message.startswith("assert 'foo' == 'bar'")
227+
# The plain asserter is used for 3.9 & below due to import issues
228+
if sys.version_info[:2] > (3, 9):
229+
assert err.message.startswith("assert 'foo' == 'bar'")
227230

228231
async with WorkflowEnvironment.from_client(client) as env:
229232
async with new_worker(env.client, AssertFailWorkflow) as worker:

Diff for: tests/worker/test_worker.py

+3-18
Original file line numberDiff line numberDiff line change
@@ -565,10 +565,10 @@ def __init__(self) -> None:
565565
async def run(self):
566566
await workflow.wait_condition(lambda: self.finish)
567567
depver = workflow.info().get_current_deployment_version()
568-
# assert depver
569-
# assert depver.build_id == "2.0"
568+
assert depver
569+
assert depver.build_id == "2.0"
570570
# Just ensuring the rust object was converted properly and this method still works
571-
# workflow.logger.debug(f"Dep string: {depver.to_canonical_string()}")
571+
workflow.logger.debug(f"Dep string: {depver.to_canonical_string()}")
572572
return "version-v2"
573573

574574
@workflow.signal
@@ -602,9 +602,6 @@ def state(self):
602602
return "v3"
603603

604604

605-
@pytest.mark.skipif(
606-
sys.version_info < (3, 12), reason="Skipping for < 3.12 due to import race bug"
607-
)
608605
async def test_worker_with_worker_deployment_config(
609606
client: Client, env: WorkflowEnvironment
610607
):
@@ -697,9 +694,6 @@ async def test_worker_with_worker_deployment_config(
697694
assert res3 == "version-v3"
698695

699696

700-
@pytest.mark.skipif(
701-
sys.version_info < (3, 12), reason="Skipping for < 3.12 due to import race bug"
702-
)
703697
async def test_worker_deployment_ramp(client: Client, env: WorkflowEnvironment):
704698
if env.supports_time_skipping:
705699
pytest.skip("Test Server doesn't support worker deployments")
@@ -790,9 +784,6 @@ async def run(self, args: Sequence[RawValue]) -> str:
790784
return "dynamic"
791785

792786

793-
@pytest.mark.skipif(
794-
sys.version_info < (3, 12), reason="Skipping for < 3.12 due to import race bug"
795-
)
796787
async def test_worker_deployment_dynamic_workflow_on_run(
797788
client: Client, env: WorkflowEnvironment
798789
):
@@ -849,9 +840,6 @@ async def run(self, args: Sequence[RawValue]) -> str:
849840
return "whee"
850841

851842

852-
@pytest.mark.skipif(
853-
sys.version_info < (3, 12), reason="Skipping for < 3.12 due to import race bug"
854-
)
855843
async def test_workflows_must_have_versioning_behavior_when_feature_turned_on(
856844
client: Client, env: WorkflowEnvironment
857845
):
@@ -886,9 +874,6 @@ async def test_workflows_must_have_versioning_behavior_when_feature_turned_on(
886874
assert "must specify a versioning behavior" in str(exc_info.value)
887875

888876

889-
@pytest.mark.skipif(
890-
sys.version_info < (3, 12), reason="Skipping for < 3.12 due to import race bug"
891-
)
892877
async def test_workflows_can_use_default_versioning_behavior(
893878
client: Client, env: WorkflowEnvironment
894879
):

0 commit comments

Comments
 (0)