Coverage for tests/unit_tests/utils/test_jsonc.py: 100%

5 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-11-06 10:20 +0000

1""" 

2Tests of jsonc.py 

3""" 

4 

5from apio.utils import jsonc 

6 

7# -- The converstion input and expected output strings. Notice the '//' within 

8# -- the string, it should not be classified as a comment. The '_' characters 

9# -- are place holders for trailing white space. 

10BEFORE = """ 

11 // Comment 1. 

12 "image": {__ 

13 // Comment 2. 

14 "src": "Images//Sun.png", // Comment 3 

15 "name": "aaa\n", 

16 "hOffset": 250 

17 } 

18""" 

19 

20AFTER = """ 

21____ 

22 "image": {__ 

23________ 

24 "src": "Images//Sun.png",_ 

25 "name": "aaa\n", 

26 "hOffset": 250 

27 } 

28""" 

29 

30 

31def test_to_json(): 

32 """Test the comments removal.""" 

33 assert jsonc.to_json(BEFORE.replace("_", " ")) == AFTER.replace("_", " ")