diff --git a/setup.cfg b/setup.cfg index 5eddf2f7..e0809914 100644 --- a/setup.cfg +++ b/setup.cfg @@ -44,7 +44,6 @@ lint = isort types-requests test = - commentjson packaging pytest release = diff --git a/tests/functional/cocoapods/test_resolvers_cocoapods.py b/tests/functional/cocoapods/test_resolvers_cocoapods.py index 12dff461..c73e4b66 100644 --- a/tests/functional/cocoapods/test_resolvers_cocoapods.py +++ b/tests/functional/cocoapods/test_resolvers_cocoapods.py @@ -5,7 +5,6 @@ import re import string -import commentjson # type: ignore import pytest from resolvelib import AbstractProvider, ResolutionImpossible, Resolver @@ -124,14 +123,16 @@ def _version_in_specset(version, specset): def _safe_json_load(filename): - # Some fixtures has comments so the stdlib implementation doesn't work. - # We only use commentjson if we absolutely need to because it's SLOW. - try: - with open(filename) as f: + # Some fixtures have comments, so strip them if first parse fails. + # We only do this in case of failure to avoid loading all JSON files to + # strings before parsing. + with open(filename) as f: + try: data = json.load(f) - except ValueError: - with open(filename) as f: - data = commentjson.load(f) + except ValueError: + f.seek(0) + strippedjson = re.sub(r"//.*$", "", f.read(), flags=re.MULTILINE) + data = json.loads(strippedjson) return data