Skip to content

Commit

Permalink
[SPARK-3867][PySpark] ./python/run-tests failed when it run with Pyth…
Browse files Browse the repository at this point in the history
…on 2.6 and unittest2 is not installed

./python/run-tests search a Python 2.6 executable on PATH and use it if available.
When using Python 2.6, it is going to import unittest2 module which is not a standard library in Python 2.6, so it fails with ImportError.

Author: cocoatomo <cocoatomo77@gmail.com>

Closes #2759 from cocoatomo/issues/3867-unittest2-import-error and squashes the following commits:

f068eb5 [cocoatomo] [SPARK-3867] ./python/run-tests failed when it run with Python 2.6 and unittest2 is not installed
  • Loading branch information
cocoatomo authored and Davies Liu committed Dec 10, 2014
1 parent 14ad3d9 commit bda1c72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion python/pyspark/mllib/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
from numpy import array, array_equal

if sys.version_info[:2] <= (2, 6):
import unittest2 as unittest
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

Expand Down
6 changes: 5 additions & 1 deletion python/pyspark/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
import zipfile

if sys.version_info[:2] <= (2, 6):
import unittest2 as unittest
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

Expand Down

0 comments on commit bda1c72

Please sign in to comment.