Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
tdas committed May 29, 2018
1 parent b9d8dd3 commit e197460
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions python/pyspark/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,15 @@ def test_tc_on_driver(self):

def test_get_local_property(self):
"""Verify that local properties set on the driver are available in TaskContext."""
self.sc.setLocalProperty("testkey", "testvalue")
rdd = self.sc.parallelize(range(1), 1)
prop1 = rdd.map(lambda x: TaskContext.get().getLocalProperty("testkey")).collect()[0]
self.assertEqual(prop1, "testkey")
prop2 = rdd.map(lambda x: TaskContext.get().getLocalProperty("otherkey")).collect()[0]
self.assertTrue(prop2 is None)

try:
self.sc.setLocalProperty("testkey", "testvalue")
rdd = self.sc.parallelize(range(1), 1)
prop1 = rdd.map(lambda x: TaskContext.get().getLocalProperty("testkey")).collect()[0]
self.assertEqual(prop1, "testvalue")
prop2 = rdd.map(lambda x: TaskContext.get().getLocalProperty("otherkey")).collect()[0]
self.assertTrue(prop2 is None)
finally:
self.sc.setLocalProperty("testkey", None)

class RDDTests(ReusedPySparkTestCase):

Expand Down

0 comments on commit e197460

Please sign in to comment.