aboutsummaryrefslogtreecommitdiff
path: root/python/pyspark/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/pyspark/tests.py')
-rw-r--r--python/pyspark/tests.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/python/pyspark/tests.py b/python/pyspark/tests.py
index 0a029b6e74..b0756911bf 100644
--- a/python/pyspark/tests.py
+++ b/python/pyspark/tests.py
@@ -409,13 +409,23 @@ class AddFileTests(PySparkTestCase):
self.assertEqual("Hello World!", res)
def test_add_file_locally(self):
- path = os.path.join(SPARK_HOME, "python/test_support/hello.txt")
+ path = os.path.join(SPARK_HOME, "python/test_support/hello/hello.txt")
self.sc.addFile(path)
download_path = SparkFiles.get("hello.txt")
self.assertNotEqual(path, download_path)
with open(download_path) as test_file:
self.assertEqual("Hello World!\n", test_file.readline())
+ def test_add_file_recursively_locally(self):
+ path = os.path.join(SPARK_HOME, "python/test_support/hello")
+ self.sc.addFile(path, True)
+ download_path = SparkFiles.get("hello")
+ self.assertNotEqual(path, download_path)
+ with open(download_path + "/hello.txt") as test_file:
+ self.assertEqual("Hello World!\n", test_file.readline())
+ with open(download_path + "/sub_hello/sub_hello.txt") as test_file:
+ self.assertEqual("Sub Hello World!\n", test_file.readline())
+
def test_add_py_file_locally(self):
# To ensure that we're actually testing addPyFile's effects, check that
# this fails due to `userlibrary` not being on the Python path:
@@ -514,7 +524,7 @@ class RDDTests(ReusedPySparkTestCase):
def test_cartesian_on_textfile(self):
# Regression test for
- path = os.path.join(SPARK_HOME, "python/test_support/hello.txt")
+ path = os.path.join(SPARK_HOME, "python/test_support/hello/hello.txt")
a = self.sc.textFile(path)
result = a.cartesian(a).collect()
(x, y) = result[0]
@@ -751,7 +761,7 @@ class RDDTests(ReusedPySparkTestCase):
b = b._reserialize(MarshalSerializer())
self.assertEqual(a.zip(b).collect(), [(0, 100), (1, 101), (2, 102), (3, 103), (4, 104)])
# regression test for SPARK-4841
- path = os.path.join(SPARK_HOME, "python/test_support/hello.txt")
+ path = os.path.join(SPARK_HOME, "python/test_support/hello/hello.txt")
t = self.sc.textFile(path)
cnt = t.count()
self.assertEqual(cnt, t.zip(t).count())
@@ -1214,7 +1224,7 @@ class InputFormatTests(ReusedPySparkTestCase):
ei = [(1, u'aa'), (1, u'aa'), (2, u'aa'), (2, u'bb'), (2, u'bb'), (3, u'cc')]
self.assertEqual(ints, ei)
- hellopath = os.path.join(SPARK_HOME, "python/test_support/hello.txt")
+ hellopath = os.path.join(SPARK_HOME, "python/test_support/hello/hello.txt")
oldconf = {"mapred.input.dir": hellopath}
hello = self.sc.hadoopRDD("org.apache.hadoop.mapred.TextInputFormat",
"org.apache.hadoop.io.LongWritable",
@@ -1233,7 +1243,7 @@ class InputFormatTests(ReusedPySparkTestCase):
ei = [(1, u'aa'), (1, u'aa'), (2, u'aa'), (2, u'bb'), (2, u'bb'), (3, u'cc')]
self.assertEqual(ints, ei)
- hellopath = os.path.join(SPARK_HOME, "python/test_support/hello.txt")
+ hellopath = os.path.join(SPARK_HOME, "python/test_support/hello/hello.txt")
newconf = {"mapred.input.dir": hellopath}
hello = self.sc.newAPIHadoopRDD("org.apache.hadoop.mapreduce.lib.input.TextInputFormat",
"org.apache.hadoop.io.LongWritable",