Skip to content

Commit

Permalink
Mock addPyFile in spark test (#2770)
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Su <pingsutw@apache.org>
  • Loading branch information
pingsutw authored Sep 27, 2024
1 parent 98d722f commit 2cf20a4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion plugins/flytekit-spark/tests/test_spark_task.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os.path
from unittest import mock

import pandas as pd
import pyspark
Expand Down Expand Up @@ -124,7 +125,8 @@ def test_to_html():
assert pd.DataFrame(df.schema, columns=["StructField"]).to_html() == output


def test_spark_addPyFile():
@mock.patch('pyspark.context.SparkContext.addPyFile')
def test_spark_addPyFile(mock_add_pyfile):
@task(
task_config=Spark(
spark_conf={"spark": "1"},
Expand Down Expand Up @@ -153,4 +155,5 @@ def my_spark(a: int) -> int:
ctx.new_execution_state().with_params(mode=ExecutionState.Mode.TASK_EXECUTION)).with_serialization_settings(serialization_settings)
) as new_ctx:
my_spark.pre_execute(new_ctx.user_space_params)
mock_add_pyfile.assert_called_once()
os.remove(os.path.join(os.getcwd(), "flyte_wf.zip"))

0 comments on commit 2cf20a4

Please sign in to comment.