Skip to content

Commit eb4ee23

Browse files
committed
Use ast.literal_eval instead of JSON parsing for stdout checks
1 parent 2b7b146 commit eb4ee23

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

tests/test_cli.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import json
6+
import ast
67
import subprocess
78
import pytest
89
import datajoint as dj
@@ -60,21 +61,8 @@ def test_cli_config():
6061
process.stdin.flush()
6162

6263
stdout, stderr = process.communicate()
63-
64-
snippet = stdout[4:519]
65-
assert snippet
66-
assert isinstance(snippet, str)
67-
try:
68-
assert dj.config == json.loads(
69-
snippet.replace("'", '"')
70-
.replace("None", "null")
71-
.replace("True", "true")
72-
.replace("False", "false")
73-
)
74-
except Exception as e:
75-
print(snippet)
76-
print(stdout)
77-
raise AssertionError(f"Error decoding JSON {snippet=}") from e
64+
cleaned = stdout.strip(" >\t\n\r")
65+
assert dj.config == ast.literal_eval(cleaned)
7866

7967

8068
def test_cli_args():

0 commit comments

Comments
 (0)