You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "bearomorphism (via GitHub)" <gi...@apache.org> on 2026/10/11 07:43:26 UTC
[PR] [MINOR][PYTHON][TEST] Cover GC state restoration in disable_gc [spark]
bearomorphism opened a new pull request, #59371:
URL: https://github.com/apache/spark/pull/59371
### What changes were proposed in this pull request?
Extend the existing `UtilTests.test_disable_gc` test in place to cover:
- Initially enabled and already-disabled GC.
- Nested contexts, checking that the inner exit does not re-enable GC.
- Exception cleanup, checking that the original GC state is restored.
Register cleanup to restore the caller's GC state even if an assertion fails. No new test class or production changes.
### Why are the changes needed?
The existing test covers only a normal exit with GC initially enabled. It does not cover the already-disabled branches or protect nested contexts and exception cleanup against regressions.
In isolated runs of this helper, the previous happy-path assertions cover 2 of 4 branch outcomes; the expanded test covers all 4. Line coverage is unchanged. These are helper-level measurements, not repository-wide coverage numbers.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
The expanded test body passed with the caller's GC initially enabled and disabled, using `unittest.FunctionTestCase` to exercise the assertions, subtests, and cleanup without starting the existing Spark fixture:
```bash
source .venv/bin/activate
PYTHONPATH=python SPARK_HOME="$PWD" python - <<'PY'
import gc
import unittest
from pyspark.tests.test_util import UtilTests
originally_enabled = gc.isenabled()
try:
for enabled, set_gc in ((True, gc.enable), (False, gc.disable)):
set_gc()
case = unittest.FunctionTestCase(lambda: UtilTests.test_disable_gc(case))
result = unittest.TextTestRunner(verbosity=2).run(case)
assert result.wasSuccessful()
assert gc.isenabled() == enabled
finally:
(gc.enable if originally_enabled else gc.disable)()
PY
ruff check python/pyspark/tests/test_util.py
ruff format --check python/pyspark/tests/test_util.py
git diff --check
```
All checks passed. A branch-coverage run of the test body confirmed all four branch outcomes in `disable_gc` are exercised. The full Spark-backed `UtilTests` fixture was not run locally because this checkout does not have a built Spark assembly.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: pi 1.1.0
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-60170][PYTHON][TEST] Cover GC state restoration in disable_gc [spark]
Posted by "gaogaotiantian (via GitHub) via reviews" <re...@spark.apache.org>.
gaogaotiantian closed pull request #59371: [SPARK-60170][PYTHON][TEST] Cover GC state restoration in disable_gc
URL: https://github.com/apache/spark/pull/59371
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-60170][PYTHON][TEST] Cover GC state restoration in disable_gc [spark]
Posted by "gaogaotiantian (via GitHub) via reviews" <re...@spark.apache.org>.
gaogaotiantian commented on PR #59371:
URL: https://github.com/apache/spark/pull/59371#issuecomment-6666892688
Thanks, this is a more comprehensive test on `disable_gc`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-60170][PYTHON][TEST] Cover GC state restoration in disable_gc [spark]
Posted by "gaogaotiantian (via GitHub) via reviews" <re...@spark.apache.org>.
gaogaotiantian commented on PR #59371:
URL: https://github.com/apache/spark/pull/59371#issuecomment-6666923385
**Merge Summary:**
- merged into master https://github.com/apache/spark/commit/11c1407582b4893c6958ba3778ec34e3c2802e5a
- merged into branch-4.x https://github.com/apache/spark/commit/760a6ab3e6ea50bab76fe0b5d8fe47857590f477
*Posted by `merge_spark_pr.py`*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org