Was able to get this to work.
What I had to do was instantiate the "sc" variable in the PySpark notebook.
PySpark code:
- "sc = spark.SparkContext"
Then in the PyTest script we add a "@patch()" statement with the "sc" variable and create a "mock_sc" variable in the function header.
PyTest code:
- "@patch(<path_to_file>.sc)"
- "def test_function(mock_sc):"
This solution properly mocked SparkContext within the PyTest script.