Skip to content

Commit fe78b8b

Browse files
andrewor14pwendell
authored andcommitted
HOTFIX: A few PySpark tests were not actually run
This is a hot fix for the hot fix in fb499be. The changes in that commit did not actually cause the `doctest` module in python to be loaded for the following tests: - pyspark/broadcast.py - pyspark/accumulators.py - pyspark/serializers.py (@pwendell I might have told you the wrong thing) Author: Andrew Or <[email protected]> Closes apache#1053 from andrewor14/python-test-fix and squashes the following commits: d2e5401 [Andrew Or] Explain why these tests are handled differently 0bd6fdd [Andrew Or] Fix 3 pyspark tests not being invoked
1 parent ce6deb1 commit fe78b8b

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

bin/pyspark

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fi
4545
. $FWDIR/bin/load-spark-env.sh
4646

4747
# Figure out which Python executable to use
48-
if [ -z "$PYSPARK_PYTHON" ] ; then
48+
if [[ -z "$PYSPARK_PYTHON" ]]; then
4949
PYSPARK_PYTHON="python"
5050
fi
5151
export PYSPARK_PYTHON
@@ -59,7 +59,7 @@ export OLD_PYTHONSTARTUP=$PYTHONSTARTUP
5959
export PYTHONSTARTUP=$FWDIR/python/pyspark/shell.py
6060

6161
# If IPython options are specified, assume user wants to run IPython
62-
if [ -n "$IPYTHON_OPTS" ]; then
62+
if [[ -n "$IPYTHON_OPTS" ]]; then
6363
IPYTHON=1
6464
fi
6565

@@ -76,6 +76,16 @@ for i in "$@"; do
7676
done
7777
export PYSPARK_SUBMIT_ARGS
7878

79+
# For pyspark tests
80+
if [[ -n "$SPARK_TESTING" ]]; then
81+
if [[ -n "$PYSPARK_DOC_TEST" ]]; then
82+
exec "$PYSPARK_PYTHON" -m doctest $1
83+
else
84+
exec "$PYSPARK_PYTHON" $1
85+
fi
86+
exit
87+
fi
88+
7989
# If a python file is provided, directly run spark-submit.
8090
if [[ "$1" =~ \.py$ ]]; then
8191
echo -e "\nWARNING: Running python applications through ./bin/pyspark is deprecated as of Spark 1.0." 1>&2
@@ -86,10 +96,6 @@ else
8696
if [[ "$IPYTHON" = "1" ]]; then
8797
exec ipython $IPYTHON_OPTS
8898
else
89-
if [[ -n $SPARK_TESTING ]]; then
90-
exec "$PYSPARK_PYTHON" -m doctest
91-
else
92-
exec "$PYSPARK_PYTHON"
93-
fi
99+
exec "$PYSPARK_PYTHON"
94100
fi
95101
fi

python/run-tests

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ function run_test() {
4444
echo -en "\033[0m" # No color
4545
exit -1
4646
fi
47-
4847
}
4948

5049
echo "Running PySpark tests. Output is in python/unit-tests.log."
@@ -55,9 +54,13 @@ run_test "pyspark/conf.py"
5554
if [ -n "$_RUN_SQL_TESTS" ]; then
5655
run_test "pyspark/sql.py"
5756
fi
57+
# These tests are included in the module-level docs, and so must
58+
# be handled on a higher level rather than within the python file.
59+
export PYSPARK_DOC_TEST=1
5860
run_test "pyspark/broadcast.py"
5961
run_test "pyspark/accumulators.py"
6062
run_test "pyspark/serializers.py"
63+
unset PYSPARK_DOC_TEST
6164
run_test "pyspark/tests.py"
6265
run_test "pyspark/mllib/_common.py"
6366
run_test "pyspark/mllib/classification.py"

0 commit comments

Comments
 (0)