This is an automated email from the ASF dual-hosted git repository.
gurwls223 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 1018f8b545a [SPARK-38827][PYTHON][TESTS] Add the test for
pyspark/find_spark_home.py
1018f8b545a is described below
commit 1018f8b545a74f4fcaf123b5f15d52ac2afa2d3c
Author: Hyukjin Kwon <[email protected]>
AuthorDate: Fri Apr 8 17:12:53 2022 +0900
[SPARK-38827][PYTHON][TESTS] Add the test for pyspark/find_spark_home.py
### What changes were proposed in this pull request?
This PR adds a test for the case when `SPARK_HOME` environment variable is
not set (see
https://app.codecov.io/gh/apache/spark/blob/master/python/pyspark/find_spark_home.py)
### Why are the changes needed?
To keep the test coverage.
### Does this PR introduce _any_ user-facing change?
No, test-only.
### How was this patch tested?
CI in this PR should test it out.
Closes #36112 from HyukjinKwon/SPARK-38827.
Authored-by: Hyukjin Kwon <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
---
python/pyspark/tests/test_util.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/python/pyspark/tests/test_util.py
b/python/pyspark/tests/test_util.py
index 7291083398d..0ba9a5852e4 100644
--- a/python/pyspark/tests/test_util.py
+++ b/python/pyspark/tests/test_util.py
@@ -14,12 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+import os
import unittest
from py4j.protocol import Py4JJavaError
from pyspark import keyword_only
from pyspark.testing.utils import PySparkTestCase
+from pyspark.find_spark_home import _find_spark_home
class KeywordOnlyTests(unittest.TestCase):
@@ -73,6 +75,15 @@ class UtilTests(PySparkTestCase):
self.assertRaises(ValueError, lambda:
VersionUtils.majorMinorVersion("abced"))
+ def test_find_spark_home(self):
+ # SPARK-38827: Test find_spark_home without `SPARK_HOME` environment
variable set.
+ origin = os.environ["SPARK_HOME"]
+ try:
+ del os.environ["SPARK_HOME"]
+ self.assertEquals(origin, _find_spark_home())
+ finally:
+ os.environ["SPARK_HOME"] = origin
+
if __name__ == "__main__":
from pyspark.tests.test_util import * # noqa: F401
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]