Skip to content

Commit

Permalink
[PySpark] Fix tests with Python 2.6 in 0.9 branch
Browse files Browse the repository at this point in the history
[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 #3668 from davies/port_2365 and squashes the following commits:

Author: cocoatomo <[email protected]>

Closes #3968 from davies/fix_python_tests and squashes the following commits:

ac4a353 [cocoatomo] [PySpark] Fix tests with Python 2.6 in 1.0 branch
  • Loading branch information
cocoatomo authored and Andrew Or committed Jan 9, 2015
1 parent 63c0ff9 commit 7d007d3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
11 changes: 10 additions & 1 deletion python/pyspark/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@
import sys
from tempfile import NamedTemporaryFile
import time
import unittest

if sys.version_info[:2] <= (2, 6):
try:
import unittest2 as unittest
except ImportError:
sys.stderr.write('Please install unittest2 to test with Python 2.6 or earlier')
sys.exit(1)
else:
import unittest


from pyspark.context import SparkContext
from pyspark.files import SparkFiles
Expand Down
10 changes: 10 additions & 0 deletions python/run-tests
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ function run_test() {
FAILED=$((PIPESTATUS[0]||$FAILED))
}

echo "Running PySpark tests. Output is in python/unit-tests.log."

# Try to test with Python 2.6, since that's the minimum version that we support:
if [ $(which python2.6) ]; then
export PYSPARK_PYTHON="python2.6"
fi

echo "Testing with Python version:"
$PYSPARK_PYTHON --version

run_test "pyspark/rdd.py"
run_test "pyspark/context.py"
run_test "pyspark/conf.py"
Expand Down

0 comments on commit 7d007d3

Please sign in to comment.