Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-50667][PYTHON][TESTS] Make jinja2 optional in PySpark Tests #49288

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/pyspark/pandas/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2632,7 +2632,7 @@ def to_latex(
... 'mask': ['red', 'purple'],
... 'weapon': ['sai', 'bo staff']},
... columns=['name', 'mask', 'weapon'])
>>> print(df.to_latex(index=False)) # doctest: +NORMALIZE_WHITESPACE
>>> print(df.to_latex(index=False)) # doctest: +SKIP
\begin{tabular}{lll}
\toprule
name & mask & weapon \\
Expand Down
2 changes: 2 additions & 0 deletions python/pyspark/pandas/tests/io/test_dataframe_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from pyspark import pandas as ps
from pyspark.testing.pandasutils import PandasOnSparkTestCase, TestUtils
from pyspark.testing.sqlutils import SQLTestUtils
from pyspark.testing.utils import have_jinja2, jinja2_requirement_message


class DataFrameConversionMixin:
Expand Down Expand Up @@ -199,6 +200,7 @@ def test_to_clipboard(self):
psdf.to_clipboard(sep=";", index=False), pdf.to_clipboard(sep=";", index=False)
)

@unittest.skipIf(not have_jinja2, jinja2_requirement_message)
def test_to_latex(self):
pdf = self.pdf
psdf = self.psdf
Expand Down
3 changes: 3 additions & 0 deletions python/pyspark/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ def have_package(name: str) -> bool:
have_flameprof = have_package("flameprof")
flameprof_requirement_message = None if have_flameprof else "No module named 'flameprof'"

have_jinja2 = have_package("jinja2")
jinja2_requirement_message = None if have_jinja2 else "No module named 'jinja2'"

pandas_requirement_message = None
try:
from pyspark.sql.pandas.utils import require_minimum_pandas_version
Expand Down
Loading