Skip to content

Commit 7b3e434

Browse files
kz930claude
andcommitted
test(visualization): read the drivers' UTF-8 files as UTF-8
The module and the Plotly page are both UTF-8, but the Carpet Plot and Filled Area drivers read them in the machine's default encoding, so on Windows the page failed with a UnicodeDecodeError at byte 0x8f. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 7e662c0 commit 7b3e434

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/carpetPlot/CarpetPlotOpDescSpec.scala‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ class CarpetPlotOpDescSpec extends AnyFlatSpec with Matchers {
161161
|import pandas as pd
162162
|import plotly.graph_objects as go
163163
|
164-
|source = pathlib.Path(sys.argv[1]).read_text()
164+
|# The module and the page are both UTF-8, which Windows does not read by
165+
|# default.
166+
|source = pathlib.Path(sys.argv[1]).read_text(encoding="utf-8")
165167
|
166168
|cases = {
167169
| "good": pd.DataFrame({"ax": [1.0, 2.0], "bx": [1.0, 2.0], "yx": [3.0, 4.0]}),
@@ -183,7 +185,7 @@ class CarpetPlotOpDescSpec extends AnyFlatSpec with Matchers {
183185
| exec(compile(source, "standalone", "exec"), scope)
184186
| # An answer page is the whole file and opens with the heading, where a
185187
| # chart is a plotly document that happens to contain any wording.
186-
| page = pathlib.Path(scope["outputHtml"]).read_text().strip()
188+
| page = pathlib.Path(scope["outputHtml"]).read_text(encoding="utf-8").strip()
187189
| if not page.startswith("<h3>"):
188190
| verdict = "CHART"
189191
| elif page.startswith("<h3>Column '"):

‎common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/filledAreaPlot/FilledAreaPlotOpDescSpec.scala‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,9 @@ class FilledAreaPlotOpDescSpec extends AnyFlatSpec with BeforeAndAfter with Matc
457457
|import pandas as pd
458458
|import plotly.express as px
459459
|
460-
|source = pathlib.Path(sys.argv[1]).read_text()
460+
|# The module and the page are both UTF-8, which Windows does not read by
461+
|# default.
462+
|source = pathlib.Path(sys.argv[1]).read_text(encoding="utf-8")
461463
|
462464
|for disjoint in (7, 8):
463465
| rows = []
@@ -474,7 +476,7 @@ class FilledAreaPlotOpDescSpec extends AnyFlatSpec with BeforeAndAfter with Matc
474476
| "px": px,
475477
| }
476478
| exec(compile(source, "standalone", "exec"), scope)
477-
| page = pathlib.Path(scope["outputHtml"]).read_text()
479+
| page = pathlib.Path(scope["outputHtml"]).read_text(encoding="utf-8")
478480
| verdict = "FALLBACK" if "not shared across all line groups" in page else "CHART"
479481
| print("CASE %d %s" % (disjoint, verdict))
480482
|""".stripMargin

0 commit comments

Comments
 (0)