Skip to content

Commit f068eb5

Browse files
committed
[SPARK-3867] ./python/run-tests failed when it run with Python 2.6 and unittest2 is not installed
1 parent 1d72a30 commit f068eb5

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
@@ -25,7 +25,11 @@
2525
from numpy import array, array_equal
2626

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

python/pyspark/tests.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
from platform import python_implementation
3535

3636
if sys.version_info[:2] <= (2, 6):
37-
import unittest2 as unittest
37+
try:
38+
import unittest2 as unittest
39+
except ImportError:
40+
sys.stderr.write('Please install unittest2 to test with Python 2.6 or earlier')
41+
sys.exit(1)
3842
else:
3943
import unittest
4044

0 commit comments

Comments
 (0)