Skip to content

[core] Import pytest lazily in test_utils to fix runtime_env_container tests - #64762

Merged
edoakes merged 5 commits into
ray-project:masterfrom
Yicheng-Lu-llll:core-lazy-import-pytest-test-utils
Jul 21, 2026
Merged

edoakes merged 5 commits into
ray-project:masterfrom
Yicheng-Lu-llll:core-lazy-import-pytest-test-utils

Conversation

@Yicheng-Lu-llll

Copy link
Copy Markdown
Member

Description

The scripts in test_runtime_env_container run inside a Ray image, which does not have pytest installed, so we can't add at the top level file but inside functions which only be called in pytest environment.

@Yicheng-Lu-llll
Yicheng-Lu-llll requested a review from a team as a code owner July 15, 2026 01:38
@Yicheng-Lu-llll Yicheng-Lu-llll added serve Ray Serve Related Issue core Issues that should be addressed in Ray Core labels Jul 15, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors python/ray/serve/_private/test_utils.py by moving the import of pytest from the global scope into the skip_if_haproxy function. No review comments were provided, so there is no feedback to address.

@Yicheng-Lu-llll Yicheng-Lu-llll added the go add ONLY when ready to merge, run all tests label Jul 15, 2026

@abrarsheikh abrarsheikh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was it working before?

@Yicheng-Lu-llll

Copy link
Copy Markdown
Member Author

@rueian Could you help merge this? Thanks!

@edoakes
edoakes merged commit 934eda2 into ray-project:master Jul 21, 2026
3 checks passed
Sparks0219 pushed a commit that referenced this pull request Jul 22, 2026
…64924)

## Description

Exclude `runtime_env_container` tests from the core flaky step: it never
builds the image they need, so they fail at setup on every postmerge
build and keep the target permanently stuck in FLAKY, even though the
actual failure was already fixed in #64762. See
https://buildkite.com/ray-project/postmerge/builds/18717#019f864f-ca0e-4241-9d23-a59644e5618b

Signed-off-by: yicheng <[email protected]>
Co-authored-by: yicheng <[email protected]>
jeffreywang88 pushed a commit that referenced this pull request Jul 27, 2026
…r tests (#64762)

## Description
The scripts in `test_runtime_env_container` run inside a Ray image,
which does not have pytest installed, so we can't add at the top level
file but inside functions which only be called in pytest environment.

Signed-off-by: yicheng <[email protected]>
Co-authored-by: yicheng <[email protected]>
elliot-barn added a commit that referenced this pull request Aug 3, 2026
…ime_env_container tests (#64762) (#64972)

Cherry-pick of #64762 (934eda2) to
`releases/2.57.0`.

## Description
Fixes the `runtime env container tests` failure on the release branch
(postmerge build
[18756](https://buildkite.com/ray-project/postmerge/builds/18756)):
`test_serve_telemetry[True/False]` fail with `ModuleNotFoundError: No
module named 'pytest'` because `ray/serve/_private/test_utils.py`
imports pytest at module level, and the scripts in
`test_runtime_env_container` run inside a Ray image which does not have
pytest installed. This change moves the import inside the functions that
need it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: yicheng <[email protected]>
Signed-off-by: elliot-barn <[email protected]>
Co-authored-by: Yicheng-Lu-llll <[email protected]>
Co-authored-by: yicheng <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…r tests (ray-project#64762)

## Description
The scripts in `test_runtime_env_container` run inside a Ray image,
which does not have pytest installed, so we can't add at the top level
file but inside functions which only be called in pytest environment.

Signed-off-by: yicheng <[email protected]>
Co-authored-by: yicheng <[email protected]>
Signed-off-by: 400Ping <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…ay-project#64924)

## Description

Exclude `runtime_env_container` tests from the core flaky step: it never
builds the image they need, so they fail at setup on every postmerge
build and keep the target permanently stuck in FLAKY, even though the
actual failure was already fixed in ray-project#64762. See
https://buildkite.com/ray-project/postmerge/builds/18717#019f864f-ca0e-4241-9d23-a59644e5618b

Signed-off-by: yicheng <[email protected]>
Co-authored-by: yicheng <[email protected]>
Signed-off-by: 400Ping <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests serve Ray Serve Related Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants