Skip to content

Commit 7d007d3

Browse files
cocoatomoAndrew Or
authored andcommitted
[PySpark] Fix tests with Python 2.6 in 0.9 branch
[PySpark] [SPARK-2954] [SPARK-2948] [SPARK-2910] [SPARK-2101] Python 2.6 Fixes - Modify python/run-tests to test with Python 2.6 - Use unittest2 when running on Python 2.6. Author: Josh Rosen <joshrosenapache.org> Closes apache#3668 from davies/port_2365 and squashes the following commits: Author: cocoatomo <cocoatomo77@gmail.com> Closes apache#3968 from davies/fix_python_tests and squashes the following commits: ac4a353 [cocoatomo] [PySpark] Fix tests with Python 2.6 in 1.0 branch
1 parent 63c0ff9 commit 7d007d3

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

python/pyspark/tests.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@
2626
import sys
2727
from tempfile import NamedTemporaryFile
2828
import time
29-
import unittest
29+
30+
if sys.version_info[:2] <= (2, 6):
31+
try:
32+
import unittest2 as unittest
33+
except ImportError:
34+
sys.stderr.write('Please install unittest2 to test with Python 2.6 or earlier')
35+
sys.exit(1)
36+
else:
37+
import unittest
38+
3039

3140
from pyspark.context import SparkContext
3241
from pyspark.files import SparkFiles

python/run-tests

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ function run_test() {
3333
FAILED=$((PIPESTATUS[0]||$FAILED))
3434
}
3535

36+
echo "Running PySpark tests. Output is in python/unit-tests.log."
37+
38+
# Try to test with Python 2.6, since that's the minimum version that we support:
39+
if [ $(which python2.6) ]; then
40+
export PYSPARK_PYTHON="python2.6"
41+
fi
42+
43+
echo "Testing with Python version:"
44+
$PYSPARK_PYTHON --version
45+
3646
run_test "pyspark/rdd.py"
3747
run_test "pyspark/context.py"
3848
run_test "pyspark/conf.py"

0 commit comments

Comments
 (0)