Created
October 29, 2018 15:15
-
-
Save mamonu/ba1a1010df49f686457ae11ec437cf15 to your computer and use it in GitHub Desktop.
pyspark fixture example
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
@pytest.fixture(scope="session") | |
def spark_context(request): | |
""" fixture for creating a spark context | |
Args: | |
request: pytest.FixtureRequest object | |
""" | |
conf = (SparkConf().setMaster("local[2]").setAppName("pytest-pyspark-local-testing")) | |
sc = SparkContext(conf=conf) | |
request.addfinalizer(lambda: sc.stop()) | |
quiet_py4j() | |
return sc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment