我在测试文件夹中有多个测试文件。结构类似于这样:
/test
----test_abc.py
----test_bcd.py
----test_cde.py
----conftest.py
py包含运行单元测试所必需的所有spark上下文初始化。我的问题是我想
test.py
在内部触发所有
test_abc.py
,
test_bcd.py
和
test_cde.py
. 当我们处理
乌斯特试验
python的模块,但我不确定如何通过
脓包
模块。如果这个问题需要进一步澄清,请告诉我。
conftest.py看起来像这样:
import pytest
from pyspark import SQLContext
from pyspark import SparkConf
from pyspark import SparkContext
from pyspark.streaming import StreamingContext
@pytest.fixture(scope="session")
def spark_context(request):
conf = (SparkConf().setMaster("local[2]").setAppName("pytest-pyspark-local-testing"))
request.addfinalizer(lambda: sc.stop())
sc = SparkContext(conf=conf).getOrCreate()
return sc
其中一个测试是这样的:
import pytest
import os
from pyspark.sql import SQLContext
pytestmark = pytest.mark.usefixtures("spark_context")
def test_get_pc_browser_sql(spark_context):
"assert something"