Skip to content

[SPARK-58081][INFRA] Document Python test base classes in AGENTS.md#57154

Open
zhengruifeng wants to merge 2 commits into
apache:masterfrom
zhengruifeng:python-test-base-classes-dev1
Open

[SPARK-58081][INFRA] Document Python test base classes in AGENTS.md#57154
zhengruifeng wants to merge 2 commits into
apache:masterfrom
zhengruifeng:python-test-base-classes-dev1

Conversation

@zhengruifeng

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Add a ## Python Test Base Classes section to AGENTS.md (CLAUDE.md is a symlink to it), right after the existing ## Scala Test Base Classes section and mirroring its structure: a short intro, an ASCII "adds capability on top of the previous" ladder, and a scope/base/notes table.

It covers:

  • the classic ladder unittest.TestCase -> PySparkBaseTestCase -> ReusedPySparkTestCase -> ReusedSQLTestCase -> PandasOnSparkTestCase, including the fresh-vs-shared SparkContext distinction (PySparkTestCase vs ReusedPySparkTestCase);
  • a ### Spark Connect test bases subsection for PlanOnlyTestFixture, ReusedConnectTestCase, and ReusedMixedTestCase, noting the should_test_connect auto-skip;
  • a ### Mixins and helpers subsection for SQLTestUtils, PySparkErrorTestUtils, the standalone assertDataFrameEqual / assertSchemaEqual, and the off-ladder domain bases (SparkSessionTestCase, MLlibTestCase, PySparkStreamingTestCase).

Why are the changes needed?

AGENTS.md already guides contributors (and AI agents) to pick the lowest suitable Scala test base class, but has no equivalent for PySpark. The Python test bases under python/pyspark/testing/ form a similar ladder that is easy to get wrong (e.g. subclassing a heavier base than needed, or missing the Connect-specific bases). Documenting them fills the adjacent gap.

Does this PR introduce any user-facing change?

No. Documentation only.

How was this patch tested?

No code changes. Verified the described class hierarchy and capabilities against the sources under python/pyspark/testing/ (utils.py, sqlutils.py, connectutils.py, pandasutils.py, mlutils.py, mllibutils.py, streamingutils.py), and spot-checked that only em-dashes (U+2014) were added as non-ASCII, consistent with the rest of the file.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 4.8)

### What changes were proposed in this pull request?

Add a `## Python Test Base Classes` section to `AGENTS.md` (`CLAUDE.md` is a
symlink to it), right after the existing `## Scala Test Base Classes` section
and mirroring its structure: a short intro, an ASCII "adds capability on top of
the previous" ladder, and a scope/base/notes table.

It covers:
- the classic ladder `unittest.TestCase` -> `PySparkBaseTestCase` ->
  `ReusedPySparkTestCase` -> `ReusedSQLTestCase` -> `PandasOnSparkTestCase`,
  including the fresh-vs-shared `SparkContext` distinction
  (`PySparkTestCase` vs `ReusedPySparkTestCase`);
- a `### Spark Connect test bases` subsection for `PlanOnlyTestFixture`,
  `ReusedConnectTestCase`, and `ReusedMixedTestCase`, noting the
  `should_test_connect` auto-skip;
- a `### Mixins and helpers` subsection for `SQLTestUtils`,
  `PySparkErrorTestUtils`, the standalone `assertDataFrameEqual` /
  `assertSchemaEqual`, and the off-ladder domain bases
  (`SparkSessionTestCase`, `MLlibTestCase`, `PySparkStreamingTestCase`).

### Why are the changes needed?

`AGENTS.md` already guides contributors (and AI agents) to pick the lowest
suitable Scala test base class, but has no equivalent for PySpark. The Python
test bases under `python/pyspark/testing/` form a similar ladder that is easy
to get wrong (e.g. subclassing a heavier base than needed, or missing the
Connect-specific bases). Documenting them fills the adjacent gap.

### Does this PR introduce _any_ user-facing change?

No. Documentation only.

### How was this patch tested?

No code changes. Verified the described class hierarchy and capabilities
against the sources under `python/pyspark/testing/` (`utils.py`, `sqlutils.py`,
`connectutils.py`, `pandasutils.py`, `mlutils.py`, `mllibutils.py`,
`streamingutils.py`), and spot-checked that only em-dashes (U+2014) were added
as non-ASCII, consistent with the rest of the file.

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 4.8)
Sharpen the ReusedMixedTestCase row: state that its purpose is to directly
compare classic vs Connect, exposing a classic `self.spark` and a Connect
`self.connect` so a test can run the same operation on each and assert they
agree.

Generated-by: Claude Code (Opus 4.8)
@pan3793

pan3793 commented Jul 9, 2026

Copy link
Copy Markdown
Member

Maybe put it under python/AGENTS.md?

@zhengruifeng

Copy link
Copy Markdown
Contributor Author

Maybe put it under python/AGENTS.md?

@pan3793 '### PySpark Tests' is also in this file, so I add the test stuffs in it.
but it is a good suggestion to move all pyspark stuffs under python/

@cloud-fan @HyukjinKwon wdyt?

@zhengruifeng zhengruifeng changed the title [INFRA] Document Python test base classes in AGENTS.md [SPARK-58081][INFRA] Document Python test base classes in AGENTS.md Jul 10, 2026
@zhengruifeng zhengruifeng marked this pull request as ready for review July 10, 2026 00:20
@HyukjinKwon

Copy link
Copy Markdown
Member

maybe let's move when it gets bigger later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants