Skip to content

Commit c62ad33

Browse files
committed
Adding Python doctest
1 parent 473ec4b commit c62ad33

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

python/pyspark/rdd.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,14 @@ def saveAsTextFile(self, path):
891891
>>> from glob import glob
892892
>>> ''.join(sorted(input(glob(tempFile.name + "/part-0000*"))))
893893
'0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n'
894+
895+
Empty lines are tolerated when saving to text files.
896+
897+
>>> tempFile2 = NamedTemporaryFile(delete=True)
898+
>>> tempFile2.close()
899+
>>> sc.parallelize(['', 'foo', '', 'bar', '']).saveAsTextFile(tempFile2.name)
900+
>>> ''.join(sorted(input(glob(tempFile2.name + "/part-0000*"))))
901+
'\\n\\n\\nbar\\nfoo\\n'
894902
"""
895903
def func(split, iterator):
896904
for x in iterator:

0 commit comments

Comments
 (0)