aboutsummaryrefslogtreecommitdiff
path: root/python/pyspark/mllib/fpm.py
diff options
context:
space:
mode:
authorWeichenXu <WeichenXu123@outlook.com>2016-05-23 18:14:48 -0700
committerAndrew Or <andrew@databricks.com>2016-05-23 18:14:48 -0700
commita15ca5533db91fefaf3248255a59c4d94eeda1a9 (patch)
tree80867e08b17b01d96611a9a695cbb1f01c0198f6 /python/pyspark/mllib/fpm.py
parent5afd927a47aa7ede3039234f2f7262e2247aa2ae (diff)
downloadspark-a15ca5533db91fefaf3248255a59c4d94eeda1a9.tar.gz
spark-a15ca5533db91fefaf3248255a59c4d94eeda1a9.tar.bz2
spark-a15ca5533db91fefaf3248255a59c4d94eeda1a9.zip
[SPARK-15464][ML][MLLIB][SQL][TESTS] Replace SQLContext and SparkContext with SparkSession using builder pattern in python test code
## What changes were proposed in this pull request? Replace SQLContext and SparkContext with SparkSession using builder pattern in python test code. ## How was this patch tested? Existing test. Author: WeichenXu <WeichenXu123@outlook.com> Closes #13242 from WeichenXu123/python_doctest_update_sparksession.
Diffstat (limited to 'python/pyspark/mllib/fpm.py')
-rw-r--r--python/pyspark/mllib/fpm.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/python/pyspark/mllib/fpm.py b/python/pyspark/mllib/fpm.py
index f339e50891..ab4066f7d6 100644
--- a/python/pyspark/mllib/fpm.py
+++ b/python/pyspark/mllib/fpm.py
@@ -183,16 +183,21 @@ class PrefixSpan(object):
def _test():
import doctest
+ from pyspark.sql import SparkSession
import pyspark.mllib.fpm
globs = pyspark.mllib.fpm.__dict__.copy()
- globs['sc'] = SparkContext('local[4]', 'PythonTest')
+ spark = SparkSession.builder\
+ .master("local[4]")\
+ .appName("mllib.fpm tests")\
+ .getOrCreate()
+ globs['sc'] = spark.sparkContext
import tempfile
temp_path = tempfile.mkdtemp()
globs['temp_path'] = temp_path
try:
(failure_count, test_count) = doctest.testmod(globs=globs, optionflags=doctest.ELLIPSIS)
- globs['sc'].stop()
+ spark.stop()
finally:
from shutil import rmtree
try: