Skip to content

Commit 8dc1ded

Browse files
cocoatomoaarondav
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 <cocoatomo77@gmail.com> 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 5b5dbe6 commit 8dc1ded

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)