Skip to content

Commit

Permalink
test_sqcmds.py: Update reading JSON to handle '/'
Browse files Browse the repository at this point in the history
NXOS in its LLDP description uses a URL without escaping the "/"
character which causes pd.read_json() to fail in mysterious ways.
This patch addresses the issue by escaping the forward slash in
the expected test output before passing it to read_json().
  • Loading branch information
ddutt committed Jan 2, 2021
1 parent 91f0681 commit ceb128a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/integration/test_sqcmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,11 @@ def _test_sqcmds(testvar, context_config):
ignore_cols = []

if 'output' in testvar:
expected_df = pd.read_json(testvar['output'].strip())
# pandas uses ujson and needs to escape "/" in any string its trying
# to decode. This is true in the case of NXOS' LLDP description which
# contains a URL causing read_json to abort with weird error messages.
expected_df = pd.read_json(
testvar['output'].strip().replace('/', '\/'))

try:
got_df = pd.read_json(output.decode('utf8').strip())
Expand Down

0 comments on commit ceb128a

Please sign in to comment.