Skip to content

Commit ed834f5

Browse files
committed
Clean unittest2 imports up added Python 2.6 before
1 parent 034ae30 commit ed834f5

19 files changed

Lines changed: 25 additions & 184 deletions

python/pyspark/ml/tests/test_algorithms.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,8 @@
1616
#
1717

1818
from shutil import rmtree
19-
import sys
2019
import tempfile
21-
22-
if sys.version_info[:2] <= (2, 6):
23-
try:
24-
import unittest2 as unittest
25-
except ImportError:
26-
sys.stderr.write('Please install unittest2 to test with Python 2.6 or earlier')
27-
sys.exit(1)
28-
else:
29-
import unittest
20+
import unittest
3021

3122
import numpy as np
3223

python/pyspark/ml/tests/test_base.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,7 @@
1515
# limitations under the License.
1616
#
1717

18-
import sys
19-
if sys.version_info[:2] <= (2, 6):
20-
try:
21-
import unittest2 as unittest
22-
except ImportError:
23-
sys.stderr.write('Please install unittest2 to test with Python 2.6 or earlier')
24-
sys.exit(1)
25-
else:
26-
import unittest
18+
import unittest
2719

2820
from pyspark.sql.types import DoubleType, IntegerType
2921
from pyspark.testing.mlutils import MockDataset, MockEstimator, MockUnaryTransformer, \

python/pyspark/ml/tests/test_evaluation.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,7 @@
1515
# limitations under the License.
1616
#
1717

18-
import sys
19-
if sys.version_info[:2] <= (2, 6):
20-
try:
21-
import unittest2 as unittest
22-
except ImportError:
23-
sys.stderr.write('Please install unittest2 to test with Python 2.6 or earlier')
24-
sys.exit(1)
25-
else:
26-
import unittest
18+
import unittest
2719

2820
import numpy as np
2921

python/pyspark/ml/tests/test_feature.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,7 @@
1717
#
1818

1919
import sys
20-
if sys.version_info[:2] <= (2, 6):
21-
try:
22-
import unittest2 as unittest
23-
except ImportError:
24-
sys.stderr.write('Please install unittest2 to test with Python 2.6 or earlier')
25-
sys.exit(1)
26-
else:
27-
import unittest
20+
import unittest
2821

2922
if sys.version > '3':
3023
basestring = str

python/pyspark/ml/tests/test_image.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616
#
17-
import sys
18-
if sys.version_info[:2] <= (2, 6):
19-
try:
20-
import unittest2 as unittest
21-
except ImportError:
22-
sys.stderr.write('Please install unittest2 to test with Python 2.6 or earlier')
23-
sys.exit(1)
24-
else:
25-
import unittest
17+
import unittest
2618

2719
import py4j
2820

python/pyspark/ml/tests/test_linalg.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,9 @@
1515
# limitations under the License.
1616
#
1717

18-
import sys
19-
if sys.version_info[:2] <= (2, 6):
20-
try:
21-
import unittest2 as unittest
22-
except ImportError:
23-
sys.stderr.write('Please install unittest2 to test with Python 2.6 or earlier')
24-
sys.exit(1)
25-
else:
26-
import unittest
27-
18+
import unittest
2819
import array as pyarray
20+
2921
from numpy import arange, array, array_equal, inf, ones, tile, zeros
3022

3123
from pyspark.ml.linalg import DenseMatrix, DenseVector, MatrixUDT, SparseMatrix, SparseVector, \

python/pyspark/ml/tests/test_param.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,7 @@
1919
import inspect
2020
import sys
2121
import array as pyarray
22-
if sys.version_info[:2] <= (2, 6):
23-
try:
24-
import unittest2 as unittest
25-
except ImportError:
26-
sys.stderr.write('Please install unittest2 to test with Python 2.6 or earlier')
27-
sys.exit(1)
28-
else:
29-
import unittest
30-
31-
if sys.version > '3':
32-
xrange = range
22+
import unittest
3323

3424
import numpy as np
3525

@@ -45,6 +35,10 @@
4535
from pyspark.testing.mlutils import check_params, PySparkTestCase, SparkSessionTestCase
4636

4737

38+
if sys.version > '3':
39+
xrange = range
40+
41+
4842
class ParamTypeConversionTests(PySparkTestCase):
4943
"""
5044
Test that param type conversion happens.

python/pyspark/ml/tests/test_persistence.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,8 @@
1717

1818
import json
1919
from shutil import rmtree
20-
import sys
2120
import tempfile
22-
if sys.version_info[:2] <= (2, 6):
23-
try:
24-
import unittest2 as unittest
25-
except ImportError:
26-
sys.stderr.write('Please install unittest2 to test with Python 2.6 or earlier')
27-
sys.exit(1)
28-
else:
29-
import unittest
21+
import unittest
3022

3123
from pyspark.ml import Transformer
3224
from pyspark.ml.classification import DecisionTreeClassifier, LogisticRegression, OneVsRest, \

python/pyspark/ml/tests/test_pipeline.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616
#
17-
import sys
18-
if sys.version_info[:2] <= (2, 6):
19-
try:
20-
import unittest2 as unittest
21-
except ImportError:
22-
sys.stderr.write('Please install unittest2 to test with Python 2.6 or earlier')
23-
sys.exit(1)
24-
else:
25-
import unittest
17+
import unittest
2618

2719
from pyspark.ml.pipeline import Pipeline
2820
from pyspark.testing.mlutils import MockDataset, MockEstimator, MockTransformer, PySparkTestCase

python/pyspark/ml/tests/test_stat.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,7 @@
1515
# limitations under the License.
1616
#
1717

18-
import sys
19-
if sys.version_info[:2] <= (2, 6):
20-
try:
21-
import unittest2 as unittest
22-
except ImportError:
23-
sys.stderr.write('Please install unittest2 to test with Python 2.6 or earlier')
24-
sys.exit(1)
25-
else:
26-
import unittest
18+
import unittest
2719

2820
from pyspark.ml.linalg import Vectors
2921
from pyspark.ml.stat import ChiSquareTest

0 commit comments

Comments
 (0)