Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: pip install click!=8.3.0
- name: Run Tests
run: hatch run test_all.py3.10:pytest -n 2 tests
timeout-minutes: 10
timeout-minutes: 15

test_py_311:
runs-on: ubuntu-latest
Expand All @@ -49,7 +49,7 @@ jobs:
run: pip install click!=8.3.0
- name: Run Tests
run: hatch run test_all.py3.11:pytest -n 2 tests
timeout-minutes: 10
timeout-minutes: 15

test_py_312:
runs-on: ubuntu-latest
Expand All @@ -68,7 +68,7 @@ jobs:
run: pip install click!=8.3.0
- name: Run Tests
run: hatch run test_all.py3.12:pytest -n 2 tests
timeout-minutes: 10
timeout-minutes: 15

lint:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6853,7 +6853,7 @@
"file name": "luminex_intelliflex_example_01.csv",
"UNC path": "tests/parsers/luminex_intelliflex/testdata/luminex_intelliflex_example_01.csv",
"ASM converter name": "allotropy_luminex_intelliflex",
"ASM converter version": "0.1.103",
"ASM converter version": "0.1.113",
"software name": "INTELLIFLEX",
"software version": "2.1.1015"
},
Expand Down
23 changes: 19 additions & 4 deletions tests/to_allotrope_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest

from allotropy.constants import CHARDET_ENCODING
from allotropy.exceptions import AllotropeConversionError
from allotropy.exceptions import AllotropeConversionError, AllotropeParsingError
from allotropy.parser_factory import Vendor
from allotropy.testing.utils import from_file, validate_contents
from allotropy.to_allotrope import allotrope_from_file, allotrope_model_from_file
Expand Down Expand Up @@ -61,9 +61,24 @@ def test_positive_cases(
).with_suffix(".json")
else:
expected_filepath = test_file_path.with_suffix(".json")
allotrope_dict = from_file(
str(test_file_path), self.VENDOR, encoding=CHARDET_ENCODING
)
# OPTIMIZATION: Try UTF-8 first for massive speedup (4x faster)
# chardet.detect() on large files (3.5MB+) can take 20+ seconds
# Most test files are UTF-8; fall back to chardet only if UTF-8 fails
try:
allotrope_dict = from_file(
str(test_file_path), self.VENDOR, encoding="UTF-8"
)
except (AllotropeConversionError, AllotropeParsingError) as e:
# If UTF-8 fails, fall back to chardet for proper encoding detection
# This is rare (only a few files with special characters)
if "utf-8" in str(e).lower() and (
"decode" in str(e).lower() or "codec" in str(e).lower()
):
allotrope_dict = from_file(
str(test_file_path), self.VENDOR, encoding=CHARDET_ENCODING
)
else:
raise
# If expected output does not exist, assume this is a new file and write it.
overwrite = overwrite or not expected_filepath.exists()
# Force overwrite should always allow overwriting
Expand Down
Loading