Skip to content

Commit bda1c72

Browse files
cocoatomoDavies Liu
authored andcommitted
[SPARK-3867][PySpark] ./python/run-tests failed when it run with Python 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 <[email protected]> Closes apache#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
1 parent 14ad3d9 commit bda1c72

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

python/pyspark/mllib/tests.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
from numpy import array, array_equal
2424

2525
if sys.version_info[:2] <= (2, 6):
26-
import unittest2 as unittest
26+
try:
27+
import unittest2 as unittest
28+
except ImportError:
29+
sys.stderr.write('Please install unittest2 to test with Python 2.6 or earlier')
30+
sys.exit(1)
2731
else:
2832
import unittest
2933

python/pyspark/tests.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
import zipfile
3232

3333
if sys.version_info[:2] <= (2, 6):
34-
import unittest2 as unittest
34+
try:
35+
import unittest2 as unittest
36+
except ImportError:
37+
sys.stderr.write('Please install unittest2 to test with Python 2.6 or earlier')
38+
sys.exit(1)
3539
else:
3640
import unittest
3741

0 commit comments

Comments
 (0)