Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions python/ray/data/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ py_library(
deps = ["//python/ray/tests:conftest"],
)

py_test_module_list(
size = "small",
files = glob(["tests/unit/**/test_*.py"]),
tags = [
"exclusive",
"team:data",
],
deps = [
":conftest",
"//:ray_lib",
],
)

py_test_module_list(
size = "medium",
files = glob(["tests/block_batching/test_*.py"]),
Expand Down
26 changes: 26 additions & 0 deletions python/ray/data/tests/unit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Unit Tests

This directory contains unit tests that do not depend on distributed infrastructure or external dependencies.

## Requirements

Unit tests in this directory must be:
- **Fast**: Execute in milliseconds, not seconds
- **Isolated**: No dependencies on Ray runtime, external services, or file I/O
- **Deterministic**: No randomness or time-based behavior

## Restrictions

Tests should NOT:
- Initialize or use the Ray distributed runtime
- Use `time.sleep()` or other time-based delays
- Depend on external services, databases, or file systems
- Make network calls

## Enforcement

The `conftest.py` in this directory enforces these restrictions by preventing:
- `ray.init()` from being called
- `time.sleep()` from being used

If a test requires any of these, it should be moved to the main test directory instead.
Empty file.
24 changes: 24 additions & 0 deletions python/ray/data/tests/unit/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import time

import pytest

import ray


@pytest.fixture(autouse=True)
def disallow_ray_init(monkeypatch):
def raise_on_init():
raise RuntimeError("Unit tests should not depend on Ray being initialized.")

monkeypatch.setattr(ray, "init", raise_on_init)


@pytest.fixture(autouse=True)
def disallow_time_sleep(monkeypatch):
def raise_on_sleep(seconds):
raise RuntimeError(
f"Unit tests should not use time.sleep({seconds}). "
"Unit tests should be fast and deterministic."
)

monkeypatch.setattr(time, "sleep", raise_on_sleep)