Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add_py_package test
  • Loading branch information
buck heroux committed Apr 13, 2016
commit 88a1d6ceffaddfc5f3aa5afc07d65a1d9ddb54e9
20 changes: 20 additions & 0 deletions python/pyspark/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from array import array
from glob import glob
import os
import os.path
import re
import shutil
import subprocess
Expand Down Expand Up @@ -1946,6 +1947,24 @@ def test_with_stop(self):
sc.stop()
self.assertEqual(SparkContext._active_spark_context, None)

def test_add_py_package(self):
name = "test_tmp"
try:
os.mkdir(name)
with open(os.path.join(name, "__init__.py"), 'w+') as temp:
temp.write("triple = lambda x: 3*x")
pkg = __import__(name)
with SparkContext() as sc:
#trips = sc.parallelize([0, 1, 2, 3]).map(test_tmp.triple)
#sc.addPyPackage(pkg)
trips = sc.parallelize([0, 1, 2, 3]).map(lambda x: pkg.triple(x))
self.assertSequenceEqual([0, 3, 6, 9], trips.collect())
finally:
shutil.rmtree(name)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the extra empty line


"""
This needs internet access
def test_requirements_file(self):
import pip
with tempfile.NamedTemporaryFile() as temp:
Expand All @@ -1956,6 +1975,7 @@ def test_requirements_file(self):
qks = sc.parallelize([(0, 0), (1, 1), (2, 2)]) \
.map(lambda pair: quadkey.from_geo(pair, 1).key)
self.assertSequenceEqual(['3', '1', '1'], qks.collect())
"""

def test_progress_api(self):
with SparkContext() as sc:
Expand Down
3 changes: 2 additions & 1 deletion python/run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
from sparktestsupport.shellutils import which, subprocess_check_output # noqa
from sparktestsupport.modules import all_modules # noqa


python_modules = dict((m.name, m) for m in all_modules if m.python_test_goals if m.name != 'root')


Expand Down Expand Up @@ -168,6 +167,8 @@ def main():
print("Error: unrecognized module '%s'. Supported modules: %s" %
(module_name, ", ".join(python_modules)))
sys.exit(-1)
#TODO REMOVE
modules_to_test = [modules_to_test[0]]
LOGGER.info("Will test against the following Python executables: %s", python_execs)
LOGGER.info("Will test the following Python modules: %s", [x.name for x in modules_to_test])

Expand Down