Skip to content

Commit eb4fa53

Browse files
author
Davies Liu
committed
fix tests in python 3
1 parent d17d634 commit eb4fa53

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

python/pyspark/java_gateway.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@
1717

1818
import atexit
1919
import os
20+
import sys
2021
import select
2122
import signal
2223
import shlex
2324
import socket
2425
import platform
2526
from subprocess import Popen, PIPE
2627

28+
if sys.version >= '3':
29+
xrange = range
30+
2731
from py4j.java_gateway import java_import, JavaGateway, GatewayClient
2832
from py4j.java_collections import ListConverter
2933

@@ -32,7 +36,7 @@
3236

3337
# patching ListConverter, or it will convert bytearray into Java ArrayList
3438
def can_convert_list(self, obj):
35-
return isinstance(obj, (list, tuple))
39+
return isinstance(obj, (list, tuple, xrange))
3640

3741
ListConverter.can_convert = can_convert_list
3842

python/pyspark/sql/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ def test_infer_long_type(self):
466466
self.assertEqual(_infer_type(2**71), LongType())
467467

468468
def test_filter_with_datetime(self):
469-
time = datetime.datetime(2015, 4, 17, 23, 01, 02, 3000)
469+
time = datetime.datetime(2015, 4, 17, 23, 1, 2, 3000)
470470
date = time.date()
471471
row = Row(date=date, time=time)
472472
df = self.sqlCtx.createDataFrame([row])

0 commit comments

Comments
 (0)