Skip to content

Commit

Permalink
Remove unnecessary warnings (#1718)
Browse files Browse the repository at this point in the history
Ensure deprecation is always warned, and simultaneously remove some unnecessary
test output clutter.
  • Loading branch information
khk-globus committed Nov 13, 2024
1 parent e6afcac commit 8db8945
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
13 changes: 13 additions & 0 deletions compute_endpoint/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,16 @@ def _pack_it(fn, *a, **k) -> bytes:
)

return _pack_it


@pytest.fixture
def htex_warns():
with pytest.warns(DeprecationWarning) as pyt_w:
yield

def _warned(msg: str) -> bool:
test = "HighThroughputEngine is deprecated" in msg
test &= "Please use GlobusComputeEngine instead" in msg
return test

assert any(_warned(str(w)) for w in pyt_w.list)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


@pytest.fixture
def engine(tmp_path):
def engine(tmp_path, htex_warns):
ep_id = uuid.uuid4()
engine = HighThroughputEngine(
label="HTEXEngine",
Expand Down
4 changes: 2 additions & 2 deletions compute_endpoint/tests/unit/test_bad_endpoint_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


@pytest.mark.parametrize("address", ("localhost", "login1.theta.alcf.anl.gov", "*"))
def test_invalid_address(address):
def test_invalid_address(address, htex_warns):
with mock.patch(f"{_MOCK_BASE}log") as mock_log:
with pytest.raises(ValueError):
HighThroughputEngine(address=address)
Expand All @@ -17,5 +17,5 @@ def test_invalid_address(address):
@pytest.mark.parametrize(
"address", ("192.168.64.12", "fe80::e643:4bff:fe61:8f72", "129.114.44.12")
)
def test_valid_address(address):
def test_valid_address(address, htex_warns):
HighThroughputEngine(address=address)
14 changes: 5 additions & 9 deletions compute_endpoint/tests/unit/test_htex.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
from tests.utils import double, ez_pack_function, try_assert


@pytest.fixture(autouse=True)
def warning_invoked(htex_warns):
yield


@pytest.fixture
def htex(tmp_path):
ep_id = uuid.uuid4()
Expand Down Expand Up @@ -99,12 +104,3 @@ def test_engine_invalid_result_data(task_id: t.Optional[str]):
htex.is_alive = False
htex._engine_bad_state.set()
queue_mgmt_thread.join()


def test_deprecation_notice(mocker):
mock_warn = mocker.patch(
"globus_compute_endpoint.engines.high_throughput.engine.warnings"
)
HighThroughputEngine()
assert mock_warn.warn.called
assert "HighThroughputEngine is deprecated" in mock_warn.warn.call_args[0][0]
2 changes: 1 addition & 1 deletion compute_endpoint/tests/unit/test_htex_facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_deprecation_notice(mocker):
assert "deprecated" in mock_warn.warn.call_args[0][0]


def test_htex_returns_engine():
def test_htex_returns_engine(htex_warns):
"""An instance of HighThroughputExecutor should now return
a HighThroughputEngine object
"""
Expand Down

0 comments on commit 8db8945

Please sign in to comment.