Created
May 10, 2020 16:13
-
-
Save priyanlc/b4367b66a8eadafeff1fe89ba9aa9657 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# conftest.py | |
import pytest | |
from pyspark import SparkConf | |
from pyspark.sql import SparkSession | |
@pytest.fixture(scope="session") | |
def spark(): | |
""" | |
Fixture for Spark Sessions. | |
we use the name `spark`, as that is is the same name you can | |
expect for the automatically injected session you find in pyspark | |
shells or pysparb Databricks notebooks. | |
""" | |
# Setup | |
spark_session = SparkSession.builder.config(conf=conf).getOrCreate() | |
yield spark_session | |
# Teardown | |
spark_session.stop() | |
conf = ( | |
SparkConf() | |
.setMaster("local") | |
.setAppName("testing") | |
.set("spark.driver.host", "localhost") | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment