I want to create a DataFrame in a fixture using the following code:
@pytest.fixture
def my_fun(spark_session):
return spark_session.createDataFrame(
[
(*['test', 'testy'])
],
T.StructType([
T.StructField('mytest', T.StringType()),
T.StructField('mytest2', T.StringType()
])
)
def test_something(my_fun):
return
However, this fails with the following error:
TypeError: StructType can not accept object 'test' in type <class 'str'>
If I use ('test', 'testy')
instead of (*['test', 'testy'])
, it works. But shouldn't this be synonymous?
(I'm using Python 3.8.13, pytest-7.0.1)