Skip to content

AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He

test: read and write fixture files as UTF-8 explicitly

hugohe344c10ed0bc3a
diff --git a/skills/ppt-master/scripts/tests/test_edit_native_batch_b.py b/skills/ppt-master/scripts/tests/test_edit_native_batch_b.py
index 5f386ead..ed964b74 100644
--- a/skills/ppt-master/scripts/tests/test_edit_native_batch_b.py
+++ b/skills/ppt-master/scripts/tests/test_edit_native_batch_b.py
@@ -628,7 +628,7 @@ class EditNativeBatchBTests(unittest.TestCase):
def test_b7_retained_diagram_and_replaced_chart_coexist(self) -> None:
self.import_source(chart=True, mutate=_diagram_fixture)
path, root = self.page()
- summary = json.loads((path.parent / 'authoring_summary.json').read_text())
+ summary = json.loads((path.parent / 'authoring_summary.json').read_text(encoding="utf-8"))
self.assertIn('"source_proxies": 1', json.dumps(summary))
marker = next(node for node in root.iter() if node.get('data-pptx-replace-with') == 'chart')
metadata = marker.find('s:metadata[@type="application/json"]', NS)
diff --git a/skills/ppt-master/scripts/tests/test_spec_review.py b/skills/ppt-master/scripts/tests/test_spec_review.py
index 4f275802..6869838a 100644
--- a/skills/ppt-master/scripts/tests/test_spec_review.py
+++ b/skills/ppt-master/scripts/tests/test_spec_review.py
@@ -253,7 +253,7 @@ class ReviewServiceTests(unittest.TestCase):
self.assertEqual(result.status_code, 200, result.get_json())
self.assertEqual(result.get_json()["validation_errors"], [])
self.assertNotIn(b"\n", self.path.read_bytes().replace(b"\r\n", b""))
- log = json.loads((self.root / "spec_review/edits.jsonl").read_text())
+ log = json.loads((self.root / "spec_review/edits.jsonl").read_text(encoding="utf-8"))
self.assertEqual(log["before_sha256"], draft["sha256"])
self.assertEqual(log["after_sha256"], sha256(self.path.read_bytes()))
self.assertIn("Edited", log["after"])
@@ -355,7 +355,7 @@ class ReviewServiceTests(unittest.TestCase):
json={"revision": updated["revision"]}).status_code, 200)
self.assertEqual(self.path.read_bytes(), before)
events = [json.loads(line)["event"] for line in
- (self.root / "spec_review/annotations.jsonl").read_text().splitlines()]
+ (self.root / "spec_review/annotations.jsonl").read_text(encoding="utf-8").splitlines()]
self.assertEqual(events, ["saved", "updated", "removed"])
def test_applied_unchanged_comment_is_removed_and_logged(self):
@@ -363,7 +363,7 @@ class ReviewServiceTests(unittest.TestCase):
self.assertEqual(self.check()[0], 0)
self.assertEqual(self.check("--applied", item["id"])[0], 0)
self.assertEqual(self.store.annotations(), [])
- self.assertIn('"event":"annotation_applied"', (self.root / "spec_review/annotations.jsonl").read_text())
+ self.assertIn('"event":"annotation_applied"', (self.root / "spec_review/annotations.jsonl").read_text(encoding="utf-8"))
def test_applied_changed_comment_is_retained(self):
item = self.store.save_annotation("slide:01", "Original")
@@ -386,7 +386,7 @@ class ReviewServiceTests(unittest.TestCase):
item = self.store.save_annotation("global", "Original")
self.check()
path = self.root / "spec_review/annotations.json"
- data = json.loads(path.read_text())
+ data = json.loads(path.read_text(encoding="utf-8"))
data["items"][0]["body"] = "Manually changed"
path.write_text(json.dumps(data), encoding="utf-8")
self.assertEqual(self.check("--applied", item["id"])[0], 1)
@@ -460,7 +460,7 @@ class ReviewServiceTests(unittest.TestCase):
self.store.save_annotation("slide:01", "Legacy feedback")
self.store.save_annotation("slide:02", "Missing block feedback")
sidecar = self.root / "spec_review/annotations.json"
- data = json.loads(sidecar.read_text())
+ data = json.loads(sidecar.read_text(encoding="utf-8"))
del data["items"][0]["block_sha256"]
sidecar.write_text(json.dumps(data), encoding="utf-8")
block = next(block for block in split_spec_blocks(SPEC).blocks if block.key == "slide:02")
@@ -508,7 +508,7 @@ class ReviewServiceTests(unittest.TestCase):
with ThreadPoolExecutor(max_workers=2) as pool:
results = list(pool.map(lambda _: apply(), range(2)))
self.assertEqual(sorted(results), [200, 409])
- self.assertEqual(len((self.root / "spec_review/edits.jsonl").read_text().splitlines()), 1)
+ self.assertEqual(len((self.root / "spec_review/edits.jsonl").read_text(encoding="utf-8").splitlines()), 1)
def test_other_block_draft_rebases_only_after_own_edit(self):
first = self.draft("slide:01")
diff --git a/skills/ppt-master/scripts/tests/test_template_flow_batch3.py b/skills/ppt-master/scripts/tests/test_template_flow_batch3.py
index 527b10b4..e2c228d9 100644
--- a/skills/ppt-master/scripts/tests/test_template_flow_batch3.py
+++ b/skills/ppt-master/scripts/tests/test_template_flow_batch3.py
@@ -160,7 +160,7 @@ class TemplateFlowBatch3Tests(unittest.TestCase):
for path in confirm.iterdir():
os.utime(path, ns=(1_000_000_000, 1_000_000_000))
self.assertIsNone(server._stage2_ready_error(self.root, confirm))
- previous = json.loads((confirm / 'template_selection.json').read_text())
+ previous = json.loads((confirm / 'template_selection.json').read_text(encoding="utf-8"))
data = _stage1()
data['revision'] = 2
_write_json(rec, data)
@@ -176,7 +176,7 @@ class TemplateFlowBatch3Tests(unittest.TestCase):
'template_selection': {'mode': 'free_design', 'selection_keys': []},
})
self.assertEqual(response.status_code, 200, response.get_json())
- current = json.loads((confirm / 'template_selection.json').read_text())
+ current = json.loads((confirm / 'template_selection.json').read_text(encoding="utf-8"))
self.assertNotEqual(previous['selection_sha256'], current['selection_sha256'])
def test_b_real_endpoints_require_install_and_selection_bound_stage2(self) -> None:
@@ -198,7 +198,7 @@ class TemplateFlowBatch3Tests(unittest.TestCase):
},
})
self.assertEqual(response.status_code, 200, response.get_json())
- selection = json.loads((confirm / 'template_selection.json').read_text())
+ selection = json.loads((confirm / 'template_selection.json').read_text(encoding="utf-8"))
rec2, final = _stage2(selection['selection_sha256'], template)
_write_json(confirm / 'recommendations.stage2.json', rec2)
if template:
@@ -221,7 +221,7 @@ class TemplateFlowBatch3Tests(unittest.TestCase):
_write_json(confirm / 'recommendations.stage2.json', rec2)
response = client.post('/api/confirm', json=final)
self.assertEqual(response.status_code, 200, response.get_json())
- result = json.loads((confirm / 'result.json').read_text())
+ result = json.loads((confirm / 'result.json').read_text(encoding="utf-8"))
self.assertEqual(result['status'], 'confirmed')
self.assertEqual(result['selection_sha256'], selection['selection_sha256'])
self.assertFalse((confirm / 'template_handoff.json').exists())
diff --git a/skills/ppt-master/scripts/tests/test_template_flow_batch4.py b/skills/ppt-master/scripts/tests/test_template_flow_batch4.py
index 3b4f7883..8a656c7d 100644
--- a/skills/ppt-master/scripts/tests/test_template_flow_batch4.py
+++ b/skills/ppt-master/scripts/tests/test_template_flow_batch4.py
@@ -121,7 +121,7 @@ class TemplateFlowBatch4Tests(unittest.TestCase):
'text_slots': [{'selector': '#missing'}],
}))
self.assertIn('unavailable', slot_capacity_report([path])['slots'][0])
- sidecar.write_text('[]')
+ sidecar.write_text('[]', encoding="utf-8")
with self.assertRaisesRegex(ValueError, 'text_slots array'):
slot_capacity_report([path])
@@ -139,7 +139,7 @@ class TemplateFlowBatch4Tests(unittest.TestCase):
self.assertFalse(any('paint order' in issue for issue in result['errors']), result['errors'])
parse_template_slide(path, 1)
# Export an attribute-based case and inspect the native shape alpha.
- path.write_text(path.read_text().replace('style="opacity:80%"', 'fill-opacity="0.8"'))
+ path.write_text(path.read_text(encoding="utf-8").replace('style="opacity:80%"', 'fill-opacity="0.8"'), encoding="utf-8")
pptx = self.root / 'scrim.pptx'
with contextlib.redirect_stdout(io.StringIO()):
self.assertTrue(create_pptx_with_native_svg(
@@ -150,14 +150,14 @@ class TemplateFlowBatch4Tests(unittest.TestCase):
self.assertEqual(len(master.findall('./p:cSld/p:bg', NS)), 1)
self.assertIsNone(master.find('./p:cSld/p:bg//a:alpha', NS))
self.assertEqual(master.find('.//p:sp/p:spPr/a:solidFill/a:srgbClr/a:alpha', NS).get('val'), '80000')
- opaque = path.read_text().replace('fill-opacity="0.8"', 'fill-opacity="1"')
- path.write_text(opaque)
+ opaque = path.read_text(encoding="utf-8").replace('fill-opacity="0.8"', 'fill-opacity="1"')
+ path.write_text(opaque, encoding="utf-8")
self.assertTrue(any('paint order' in issue for issue in
SVGQualityChecker(template_mode=True).check_file(str(path))['errors']))
for inherited in ('fill-opacity="0.8"', 'style="opacity:0.8"'):
with self.subTest(inherited=inherited):
path.write_text(opaque.replace('fill-opacity="1"', '').replace(
- 'data-pptx-layout="l"', f'data-pptx-layout="l" {inherited}'))
+ 'data-pptx-layout="l"', f'data-pptx-layout="l" {inherited}'), encoding="utf-8")
self.assertFalse(any('paint order' in issue for issue in
SVGQualityChecker(template_mode=True).check_file(str(path))['errors']))
parse_template_slide(path, 1)