Skip to content

Commit bb73c61

Browse files
committed
test(providers): relocate provider-base scaffolding tests into unit leg
#287 added scaffolding/exceptions/strategy tests under tests/providers/base/, but the providers CI leg only runs discovered provider subtrees (aws, k8s via testconf.mk) and the unit leg runs tests/unit — so tests/providers/base ran in NO CI leg. Move them into tests/unit/providers/base/ so the unit leg executes them. Also replace the deprecated asyncio.get_event_loop().run_until_complete() with asyncio.run() in the handler-base tests — get_event_loop() raises under Python 3.12 once another test has closed the global loop, which surfaced as order-dependent failures now that these run in the shared unit leg.
1 parent f01dc10 commit bb73c61

8 files changed

Lines changed: 7 additions & 7 deletions

File tree

tests/providers/base/scaffolding/__init__.py

Whitespace-only changes.

tests/providers/base/strategy/__init__.py

Whitespace-only changes.
File renamed without changes.

tests/providers/base/exceptions/test_provider_error.py renamed to tests/unit/providers/base/exceptions/test_provider_error.py

File renamed without changes.
File renamed without changes.

tests/providers/base/scaffolding/test_handler_base.py renamed to tests/unit/providers/base/scaffolding/test_handler_base.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def setup_method(self):
120120

121121
def test_acquire_hosts_raises(self):
122122
with pytest.raises(NotImplementedError, match="acquire_hosts"):
123-
asyncio.get_event_loop().run_until_complete(
123+
asyncio.run(
124124
self.handler.acquire_hosts(object(), object())
125125
)
126126

@@ -130,7 +130,7 @@ def test_check_hosts_status_raises(self):
130130

131131
def test_release_hosts_raises(self):
132132
with pytest.raises(NotImplementedError, match="release_hosts"):
133-
asyncio.get_event_loop().run_until_complete(self.handler.release_hosts(["i-abc123"]))
133+
asyncio.run(self.handler.release_hosts(["i-abc123"]))
134134

135135
def test_cancel_resource_raises(self):
136136
with pytest.raises(NotImplementedError, match="cancel_resource"):
@@ -143,7 +143,7 @@ def test_get_example_templates_raises(self):
143143
def test_not_implemented_message_contains_classname(self):
144144
"""Error message should name the class so developers know which handler to fix."""
145145
with pytest.raises(NotImplementedError) as exc_info:
146-
asyncio.get_event_loop().run_until_complete(
146+
asyncio.run(
147147
self.handler.acquire_hosts(object(), object())
148148
)
149149
assert "_BareHandler" in str(exc_info.value)
@@ -178,7 +178,7 @@ def setup_method(self):
178178
self.handler = _ConcreteHandler()
179179

180180
def test_acquire_hosts_returns_result(self):
181-
result = asyncio.get_event_loop().run_until_complete(
181+
result = asyncio.run(
182182
self.handler.acquire_hosts(object(), object())
183183
)
184184
assert result["resource_ids"] == ["r-1"]
@@ -188,18 +188,18 @@ def test_check_hosts_status_returns_result(self):
188188
assert "instances" in result
189189

190190
def test_release_hosts_returns_none(self):
191-
result = asyncio.get_event_loop().run_until_complete(self.handler.release_hosts(["i-1"]))
191+
result = asyncio.run(self.handler.release_hosts(["i-1"]))
192192
assert result is None
193193

194194
def test_release_hosts_accepts_context_dict(self):
195195
ctx = {"namespace": "default", "resource_mapping": {"i-1": ("fleet-1", 1)}}
196-
result = asyncio.get_event_loop().run_until_complete(
196+
result = asyncio.run(
197197
self.handler.release_hosts(["i-1"], context=ctx)
198198
)
199199
assert result is None
200200

201201
def test_release_hosts_accepts_none_context(self):
202-
result = asyncio.get_event_loop().run_until_complete(
202+
result = asyncio.run(
203203
self.handler.release_hosts(["i-1"], context=None)
204204
)
205205
assert result is None

tests/providers/base/scaffolding/test_registration.py renamed to tests/unit/providers/base/scaffolding/test_registration.py

File renamed without changes.

tests/providers/base/strategy/test_get_resource_id_pattern.py renamed to tests/unit/providers/base/strategy/test_get_resource_id_pattern.py

File renamed without changes.

0 commit comments

Comments
 (0)