11import importlib
22import subprocess
33import sys
4- import textwrap
54import warnings
65
7- import pytest
8-
96# TODO: Remove these tests with the compatibility bridge in the next breaking-change release.
107INTERRUPT_MODEL_NAMES = (
118 "CreateBatchTransform" ,
@@ -62,8 +59,6 @@ def test_compatibility_exports_are_canonical_objects():
6259
6360 assert set (INTERRUPT_MODEL_NAMES ) == set (legacy .__all__ )
6461 assert set (INTERRUPT_MODEL_NAMES ) <= set (common .__all__ )
65- assert set (legacy .__all__ ) <= set (dir (legacy ))
66- assert set (INTERRUPT_MODEL_NAMES ) <= set (dir (common ))
6762
6863
6964def test_importing_common_does_not_load_resume_triggers_or_warn ():
@@ -83,30 +78,16 @@ def test_importing_common_does_not_load_resume_triggers_or_warn():
8378 )
8479
8580
86- @pytest .mark .parametrize (
87- "imports" ,
88- [
89- """
90- from uipath.platform.resume_triggers import WaitUntil as canonical
91- from uipath.platform.common import WaitUntil as legacy_root
92- from uipath.platform.common.interrupt_models import WaitUntil as legacy_direct
93- """ ,
94- """
95- from uipath.platform.common.interrupt_models import WaitUntil as legacy_direct
96- from uipath.platform.common import WaitUntil as legacy_root
97- from uipath.platform.resume_triggers import WaitUntil as canonical
98- """ ,
99- ],
100- )
101- def test_import_orders_are_cycle_safe (imports : str ):
102- indented_imports = textwrap .indent (imports .strip (), " " )
81+ def test_legacy_first_import_is_cycle_safe_and_warns ():
10382 _run_python (
104- f """
83+ """
10584import warnings
10685
10786with warnings.catch_warnings(record=True) as caught:
10887 warnings.simplefilter("always")
109- { indented_imports }
88+ from uipath.platform.common.interrupt_models import WaitUntil as legacy_direct
89+ from uipath.platform.common import WaitUntil as legacy_root
90+ from uipath.platform.resume_triggers import WaitUntil as canonical
11091
11192assert canonical is legacy_root is legacy_direct
11293compatibility_warnings = [
@@ -118,66 +99,3 @@ def test_import_orders_are_cycle_safe(imports: str):
11899assert compatibility_warnings
119100"""
120101 )
121-
122-
123- def test_legacy_imports_warn_at_caller_site ():
124- _run_python (
125- """
126- import warnings
127-
128- with warnings.catch_warnings(record=True) as caught:
129- warnings.simplefilter("always")
130- from uipath.platform.common import WaitUntil
131- from uipath.platform.common.interrupt_models import WaitTask
132-
133- compatibility_warnings = [
134- item
135- for item in caught
136- if issubclass(item.category, DeprecationWarning)
137- and "uipath.platform.resume_triggers" in str(item.message)
138- ]
139- assert len(compatibility_warnings) == 2
140- assert all(item.filename == "<string>" for item in compatibility_warnings), [
141- item.filename for item in compatibility_warnings
142- ]
143- """
144- )
145-
146-
147- def test_cached_resolution_warns_once_per_name ():
148- _run_python (
149- """
150- import warnings
151-
152- import uipath.platform.common as common
153-
154- with warnings.catch_warnings(record=True) as caught:
155- warnings.simplefilter("always")
156- common.WaitUntil
157- common.WaitUntil
158- common.WaitJob
159-
160- compatibility_warnings = [
161- item
162- for item in caught
163- if issubclass(item.category, DeprecationWarning)
164- and "uipath.platform.resume_triggers" in str(item.message)
165- ]
166- assert len(compatibility_warnings) == 2
167- """
168- )
169-
170-
171- def test_star_import_exports_all_interrupt_models ():
172- _run_python (
173- """
174- import warnings
175-
176- warnings.simplefilter("ignore", DeprecationWarning)
177-
178- from uipath.platform.common.interrupt_models import * # noqa: F403
179-
180- for name in ("InvokeProcess", "WaitUntil", "CreateTask", "WaitIntegrationEvent"):
181- assert name in globals(), name
182- """
183- )
0 commit comments