PyTest random order for Fabric tests (#19040)

This commit is contained in:
Adrian Wälchli 2023-11-22 22:41:49 +01:00 committed by GitHub
parent c6e5e34d1f
commit da79480054
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -165,7 +165,7 @@ jobs:
# NOTE: do not include coverage report here, see: https://github.com/nedbat/coveragepy/issues/1003
run: |
python -m coverage run --source ${{ env.COVERAGE_SCOPE }} \
-m pytest -v --timeout=30 --durations=50
-m pytest -v --timeout=30 --durations=50 --random-order-seed=$GITHUB_RUN_ID
- name: Statistics
if: success()

View File

@ -20,12 +20,12 @@ from lightning.fabric.utilities.rank_zero import _get_rank
({"JSM_NAMESPACE_RANK": "4"}, None),
],
)
def test_rank_zero_known_environment_variables(env_vars, expected):
def test_rank_zero_known_environment_variables(env_vars, expected, monkeypatch):
"""Test that rank environment variables are properly checked for rank_zero_only."""
with mock.patch.dict(os.environ, env_vars):
# force module reload to re-trigger the rank_zero_only.rank global computation
sys.modules.pop("lightning_utilities.core.rank_zero", None)
sys.modules.pop("lightning.fabric.utilities.rank_zero", None)
monkeypatch.delitem(sys.modules, "lightning_utilities.core.rank_zero", raising=False)
monkeypatch.delitem(sys.modules, "lightning.fabric.utilities.rank_zero", raising=False)
from lightning.fabric.utilities.rank_zero import rank_zero_only
@rank_zero_only