@@ -295,3 +295,102 @@ def test_custom_changelog_path():
295
295
# Check changelog was updated
296
296
updated_changelog = custom_changelog_path .read_text ()
297
297
assert "- Add new feature [#456](https://github.com/egraphs-good/egglog-python/pull/456)" in updated_changelog
298
+
299
+
300
+ def test_update_changelog_with_markdown_backticks ():
301
+ """Test that PR titles with markdown backticks are preserved correctly."""
302
+ with tempfile .TemporaryDirectory () as temp_dir :
303
+ temp_path = Path (temp_dir )
304
+
305
+ # Create mock changelog
306
+ changelog_content = """# Changelog
307
+
308
+ ## UNRELEASED
309
+
310
+ ## 1.2.3 (2024-01-01)
311
+
312
+ - Some old change
313
+ """
314
+ docs_dir = temp_path / "docs"
315
+ docs_dir .mkdir ()
316
+ changelog_path = docs_dir / "changelog.md"
317
+ changelog_path .write_text (changelog_content )
318
+
319
+ # Test with title containing markdown backticks
320
+ pr_title_with_backticks = "Support methods like `__array_function__` on expressions"
321
+
322
+ # Run the script
323
+ result = subprocess .run (
324
+ [
325
+ sys .executable ,
326
+ str (Path (__file__ ).parent .parent .parent / "modify_changelog.py" ),
327
+ "update_changelog" ,
328
+ "315" ,
329
+ pr_title_with_backticks ,
330
+ ],
331
+ capture_output = True ,
332
+ text = True ,
333
+ cwd = temp_path ,
334
+ check = False ,
335
+ )
336
+
337
+ assert result .returncode == 0
338
+ assert f"Added changelog entry for PR #315: { pr_title_with_backticks } " in result .stdout
339
+
340
+ # Check that backticks are preserved in the changelog
341
+ updated_changelog = changelog_path .read_text ()
342
+ expected_entry = f"- { pr_title_with_backticks } [#315](https://github.com/egraphs-good/egglog-python/pull/315)"
343
+ assert expected_entry in updated_changelog
344
+
345
+ # Specifically check that the backticks around __array_function__ are preserved
346
+ assert "`__array_function__`" in updated_changelog
347
+
348
+
349
+ def test_update_changelog_multiple_backticks ():
350
+ """Test that PR titles with multiple markdown elements are preserved correctly."""
351
+ with tempfile .TemporaryDirectory () as temp_dir :
352
+ temp_path = Path (temp_dir )
353
+
354
+ # Create mock changelog
355
+ changelog_content = """# Changelog
356
+
357
+ ## UNRELEASED
358
+
359
+ ## 1.2.3 (2024-01-01)
360
+
361
+ - Some old change
362
+ """
363
+ docs_dir = temp_path / "docs"
364
+ docs_dir .mkdir ()
365
+ changelog_path = docs_dir / "changelog.md"
366
+ changelog_path .write_text (changelog_content )
367
+
368
+ # Test with title containing multiple markdown elements
369
+ pr_title_complex = "Fix `__getattr__` and add support for `__setitem__` methods"
370
+
371
+ # Run the script
372
+ result = subprocess .run (
373
+ [
374
+ sys .executable ,
375
+ str (Path (__file__ ).parent .parent .parent / "modify_changelog.py" ),
376
+ "update_changelog" ,
377
+ "999" ,
378
+ pr_title_complex ,
379
+ ],
380
+ capture_output = True ,
381
+ text = True ,
382
+ cwd = temp_path ,
383
+ check = False ,
384
+ )
385
+
386
+ assert result .returncode == 0
387
+ assert f"Added changelog entry for PR #999: { pr_title_complex } " in result .stdout
388
+
389
+ # Check that all backticks are preserved in the changelog
390
+ updated_changelog = changelog_path .read_text ()
391
+ expected_entry = f"- { pr_title_complex } [#999](https://github.com/egraphs-good/egglog-python/pull/999)"
392
+ assert expected_entry in updated_changelog
393
+
394
+ # Specifically check that both sets of backticks are preserved
395
+ assert "`__getattr__`" in updated_changelog
396
+ assert "`__setitem__`" in updated_changelog
0 commit comments