Skip to content

Commit

Permalink
Adjust for improved JSON error messages in Python 3.13
Browse files Browse the repository at this point in the history
The fix for python/cpython#113149 changed this
error message.

Closes: #1092519
  • Loading branch information
cjwatson committed Jan 12, 2025
1 parent 155309c commit 61f32e7
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions tests/test_ionit.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import os
import re
import sys
import unittest

from ionit import collect_context, main, render_templates
Expand Down Expand Up @@ -112,14 +113,24 @@ def test_invalid_json(self):
collect_context([os.path.join(CONFIG_DIR, "invalid-json")], "utf-8"), (1, {})
)
self.assertEqual(len(context_manager.output), 1)
self.assertRegex(
context_manager.output[0],
(
"ERROR:ionit:Failed to read JSON from "
"'[^']*config/invalid-json/invalid.json': Expecting property name "
r"enclosed in double quotes: line 3 column 1 \(char 22\)"
),
)
if sys.version_info >= (3, 13):
self.assertRegex(
context_manager.output[0],
(
"ERROR:ionit:Failed to read JSON from "
"'[^']*config/invalid-json/invalid.json': Illegal trailing comma before "
r"end of object: line 2 column 19 \(char 20\)"
),
)
else:
self.assertRegex(
context_manager.output[0],
(
"ERROR:ionit:Failed to read JSON from "
"'[^']*config/invalid-json/invalid.json': Expecting property name "
r"enclosed in double quotes: line 3 column 1 \(char 22\)"
),
)

def test_invalid_python(self):
"""Test: Run collect_context(["tests/config/invalid-python"])"""
Expand Down

0 comments on commit 61f32e7

Please sign in to comment.