-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
utils: fix autoDecode error for specific sequence
Since we're probably going to be seeing either ASCII or UTF-8 input anyway, bump the detection confidence requirement from 0.5 to 0.8. In the case of the first test input shown in utils_test.py, it was coming in at 0.559 for Windows-1254 and just 0.505 for UTF-8, when in fact, it's UTF-8. This also makes me question using chardet at all, but it probably won't hurt at the new confidence threshold.
- Loading branch information
Showing
2 changed files
with
21 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env python | ||
# Copyright (c) 2021 Arista Networks, Inc. All rights reserved. | ||
# Arista Networks, Inc. Confidential and Proprietary. | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
||
import pytest | ||
|
||
from jobrunner.utils import autoDecode | ||
|
||
|
||
@pytest.mark.parametrize(("value", "encoding"), [ | ||
(b"Waiting for '\xe2\x9d\xaf|[Pp]db' in session " | ||
b"routing-enabled-structure_0_64\n(Pdb++)\n", "utf-8"), | ||
(b"hi there", "ascii"), | ||
]) | ||
def testAutoDecode(value, encoding): | ||
assert value.decode(encoding) == autoDecode(value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters