Skip to content

Commit

Permalink
[SPARK-2470] PEP8 fixes to tests.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nchammas committed Jul 20, 2014
1 parent 8f8e4c0 commit 7d557b7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions python/pyspark/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ class PySparkTestCase(unittest.TestCase):
def setUp(self):
self._old_sys_path = list(sys.path)
class_name = self.__class__.__name__
self.sc = SparkContext('local[4]', class_name , batchSize=2)
self.sc = SparkContext('local[4]', class_name, batchSize=2)

def tearDown(self):
self.sc.stop()
sys.path = self._old_sys_path


class TestCheckpoint(PySparkTestCase):

def setUp(self):
Expand Down Expand Up @@ -190,24 +191,27 @@ def test_deleting_input_files(self):

def testAggregateByKey(self):
data = self.sc.parallelize([(1, 1), (1, 1), (3, 2), (5, 1), (5, 3)], 2)

def seqOp(x, y):
x.add(y)
return x

def combOp(x, y):
x |= y
return x

sets = dict(data.aggregateByKey(set(), seqOp, combOp).collect())
self.assertEqual(3, len(sets))
self.assertEqual(set([1]), sets[1])
self.assertEqual(set([2]), sets[3])
self.assertEqual(set([1, 3]), sets[5])


class TestIO(PySparkTestCase):

def test_stdout_redirection(self):
import subprocess

def func(x):
subprocess.check_call('ls', shell=True)
self.sc.parallelize([1]).foreach(func)
Expand Down Expand Up @@ -479,7 +483,7 @@ def test_module_dependency(self):
| return x + 1
""")
proc = subprocess.Popen([self.sparkSubmit, "--py-files", zip, script],
stdout=subprocess.PIPE)
stdout=subprocess.PIPE)
out, err = proc.communicate()
self.assertEqual(0, proc.returncode)
self.assertIn("[2, 3, 4]", out)
Expand Down

0 comments on commit 7d557b7

Please sign in to comment.