Coverage for tests/unit_tests/utils/test_jsonc.py: 100%
5 statements
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-07 05:08 +0000
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-07 05:08 +0000
1# This file is part of the Apio project
2# (C) 2016-present FPGAwars
3# Project authors:
4# * Jesús Arroyo (Jesus89) (2016-2019)
5# * Juan Gonzalez (obijuan) (2019-2024)
6# * The Apio Team (2024-present)
7# License: GPLv2
9"""
10Tests of jsonc.py
11"""
13from apio.utils import jsonc
15# -- The conversion input and expected output strings. Notice the '//' within
16# -- the string, it should not be classified as a comment. The '_' characters
17# -- are place holders for trailing white space.
18BEFORE = """
19 // Comment 1.
20 "image": {__
21 // Comment 2.
22 "src": "Images//Sun.png", // Comment 3
23 "name": "aaa\n",
24 "hOffset": 250
25 }
26"""
28AFTER = """
29____
30 "image": {__
31________
32 "src": "Images//Sun.png",_
33 "name": "aaa\n",
34 "hOffset": 250
35 }
36"""
39def test_to_json():
40 """Test the comments removal."""
41 assert jsonc.to_json(BEFORE.replace("_", " ")) == AFTER.replace("_", " ")